I keep getting minor errors I can't figure out and I don't know how to convert...

80.2K

Verified Solution

Question

Programming

I keep getting minor errors I can't figure out and I don't knowhow to convert decimal .10 to percentage 10%either.  
With these functions defined now expand the program for a companywho gives discounts on items bought in bulk.
Create a main function and inside of it ask the user how manydifferent items they are buying.
For each item have the user input a price and quantity, validatingthem with the functions that you wrote.
Use your discount function to find the discount for each item'squantity and calculate the discounted price.
Print the discounted price in $9,999.99 format

Sum the discounted totals for all items and display this grandtotal at the end.
Print the percentages in 99.9% format.

In addition to summing the discounted totals, also sum theun-discounted totals.
At the end display both of these values and then calculate andprint the overall percentage saved in 99.9% format.

def discount ():
discount = 0.00
if quantity >= 0 and quantity <= 19 :
discount = 0.00
if quantity >= 20 and quantity >= 49 :
discount = 0.05
if quantity >= 50 and quantity <= 99 :
discount = 0.08
if quantity >= 100 :
discount = 0.10
return discount
# user input quantity
def quantity ():
quantity = 0
quantity = int (input ('What is the quantity? '))
while quantity < 1 or quantity > 2000 :
print ('Error, Please enter a quantity between 1 and 2000.')
quantity = int (input ('What is the quantity? '))
return quantity
# user input price
def price ():
price = 0.0
price = float (input ('What is the price? '))
while price < 0.0 :
print ('Error, the price must be greater than $0.00')
price = float (input ('What is the price? '))
return price
# main
def main ():
for i in range (items)   
items = int (input ('How many different items are you purchasing?'))
quantity ()
discount ()
price ()
Total_price = sum (price)
Total_discount = sum (discount)
Discounted_price = price - (price * discount)
Total_Discounted_price = Total_price - (Total_price *Total_discount)
print ('For item ',i +1,,' ' Discounted_price, ' with a ',discount, format (.2f, sep=''))
print ('Total order is ', Total_Discounted_price, ' with a ',Total_discount, format (.2f, sep=''))
#initiate
main ()

Answer & Explanation Solved by verified expert
4.3 Ratings (891 Votes)
def discount qd 000if q 0 and q 20 and q 49 d 005if q 50 and q 100 d 010return d user input quantitydef quantity q 0q int input What is the quantity while q 1 or q 2000 print Error    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students