137k views
6 votes
company gives the following discount if you purchase a large amount of supply. Units Bought Discount 10 - 19 20% 20 - 49 30% 50 - 99 35% 100 40% If each item is $4.10. Create a program that asks the user how many items they want to buy, then calculates the pre-discount price, the amount of discount and the after discount price. So for example if order 101 items, I should see something similar to the following: With your order of 101 items, the total value will be $414.10 with a discount of $165.64 for a final price of $248.46. Your output should be very well organized, and use the correct formatting. (Including precision)

User Ken Prince
by
3.4k points

1 Answer

13 votes

Answer:

In Python:

order = int(input("Order: "))

discount = 0

if(order >= 10 and order <20):

discount = 0.20

elif(order >= 20 and order <50):

discount = 0.30

elif(order >= 50 and order <100):

discount = 0.35

elif(order >= 100):

discount = 0.40

price = order * 4.1

discount = discount * price

print("With your order of "+str(order)+" items, the total value will be $"+str(round(price,2))+" with a discount of $"+str(round(discount,2))+" for a final price of $"+str(round((price-discount),2)))

Step-by-step explanation:

This prompts the user for number of orders

order = int(input("Order: "))

This initializes the discount to 0

discount = 0

For orders between 10 and 19 (inclusive)

if(order >= 10 and order <20):

-----------discount is 20%

discount = 0.20

For orders between 20 and 49 (inclusive)

elif(order >= 20 and order <50):

-----------discount is 30%

discount = 0.30

For orders between 50 and 99 (inclusive)

elif(order >= 50 and order <100):

-----------discount is 35%

discount = 0.35

For orders greater than 99

elif(order >= 100):

-----------discount is 40%

discount = 0.40

This calculates the total price

price = order * 4.1

This calculates the pre discount

discount = discount * price

This prints the report

print("With your order of "+str(order)+" items, the total value will be $"+str(round(price,2))+" with a discount of $"+str(round(discount,2))+" for a final price of $"+str(round((price-discount),2)))

User GulBrillo
by
3.2k points