Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A hardware store awards coupons depending on how much a customer spends. For exa

ID: 3749477 • Letter: A

Question

A hardware store awards coupons depending on how much a customer spends. For example, if you spend $45, you will get a coupon worth 5% percent of that amount. The following table shows the percent used to calculate the coupon awarded for different amounts spent. Write a program that calculates and prints the value of the coupon a person can receive based on the items purchased, and the amount paid after the discount is applied. Money Spent Coupon Percent Less than $10 No coupon Between $10 and $50 5% Between $50 and $75 10% Between $75 and $125 15% Between $125 and $200 18% More than $200 20% Note, as specified, it is not clear how to handle boundary conditions. For example, what is the coupon percent for $125.25? Is the discount 15% or 18%? You should decide how you are going to handle boundary conditions and be sure to explain your choice in the program documentation.

Explanation / Answer

amt=float(input("Enter the price of goods-")) #taking price of first item
while(1):
   print ("Enter any alpha key for totaling")
   x=(input("Enter the price of goods-"))
   if (x.isdigit()): # check amout is digit or not if not then quit the loop
       amt+=float(x)
   else:
       break

dis = 0
if (amt<10): #assigning the disocount according to total amount
   dis = 0
elif (amt>=10 and amt<50):
   dis = 5
elif (amt>=50 and amt<75):
   dis = 10
elif (amt>=75 and amt<125):
   dis = 15
elif (amt>=125 and amt<200):
   dis = 18
else:
   dis = 20

dis_amt=amt*dis/100 # calculating discount
print ("Amount                ",amt)
print ("Discount ",dis,"%         ",dis_amt)
print ("Net Amount            ",amt-dis_amt)

I have decided to handle boundary condition like amount between two variable include all the float value between them. like 20.5$ comes under amount between 10$ and 50$

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote