99.7k views
2 votes
Create an algorithm that will read in the subtotal of an order. Calculate and print the discount applied and the new subtotal after the discount has been applied. If the subtotal is greater than $100, the discount to be applied is 40%, otherwise the discount to be applied is 25%. The new subtotal is calculated by subtracting the discount applied from the subtotal.

A) Read in the subtotal, apply a 40% discount if the subtotal is greater than $100, and calculate the new subtotal by subtracting the discount from the subtotal.

B) Read in the subtotal, apply a 25% discount if the subtotal is greater than $100, and calculate the new subtotal by subtracting the discount from the subtotal.

C) Read in the subtotal, apply a 15% discount if the subtotal is greater than $50, and calculate the new subtotal by subtracting the discount from the subtotal.

D) Read in the subtotal, apply a 10% discount if the subtotal is greater than $200, and calculate the new subtotal by subtracting the discount from the subtotal.

1 Answer

2 votes

Final answer:

To create an algorithm that calculates the discount applied and the new subtotal after the discount has been applied, follow these steps: read in the subtotal, check if it's greater than $100, calculate the discount based on the subtotal, subtract the discount from the subtotal, and print the discount applied and the new subtotal.

Step-by-step explanation:

To create an algorithm that calculates and prints the discount applied and the new subtotal after the discount has been applied, you can follow the steps below:

- Read in the subtotal of the order.

- If the subtotal is greater than $100, calculate the discount as 40% of the subtotal. Otherwise, calculate the discount as 25% of the subtotal.

- Subtract the discount from the subtotal to get the new subtotal.

- Print the discount applied and the new subtotal.

For example:

subtotal = read_input()
if subtotal > 100:
discount = subtotal * 0.4
else:
discount = subtotal * 0.25
new_subtotal = subtotal - discount
print('Discount applied:', discount)
print('New subtotal:', new_subtotal)

User Jumogehn
by
7.4k points