In Python A software compant sells a package that retails fo
In Python
A software compant sells a package that retails for $99. Quantity discounts are given according to the following
10-19 is given a 10% discount
20-49 is given a 20% discount
50-99 is given a 30% discount
100 or more is given a 40% discount
Write a program that asks the user to enter the nmber of packages purchased. the program should then displa the amount of the discount (if any) and the total aount of the purchase after discount.
Include the following:
A section for input
A section for processing and calculation of the discount and total amount of purchase
A section to print or display the total amount of purchase and discount
Follow the structure of input, processing, output learned in Unit 3.
A properly structured elif statement to calculate discount, do not use nested if/else.
Properly named variables
Solution
The following code will give you the required functionality:
# your code goes here
n = int(input(\'Enter the number of packages purchased\'))
rate = n*99
discount = 0.0
if(n>=10 and n<=19):
discount = 0.1 * rate
elif (n>=20 and n<=49):
discount = 0.2 * rate
elif (n>=50 and n<=99):
discount = 0.3 * rate
elif (n>=100):
discount = 0.4 * rate
total_amount = rate - discount
print(\'Discount given: \'+ str(discount))
print(\'Total payable amount: \'+ str(total_amount))
Output:
Discount given: 99.0
Total payable amount: 891.0
The following URL have the interpreted version of the code:
http://ideone.com/hHX9Wq
Hope it helps. DO comment your response.
