-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path3.12. Software Sales.py
41 lines (41 loc) · 1.5 KB
/
3.12. Software Sales.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
12. Software Sales
A software company sells a package that retails for $99.
Quantity discounts are given according to the following table:
Quantity Discount
10_19 10%
20_49 20%
50_99 30%
100 or more 40%
Write a program that asks the user to enter the number of packages purchased.
The program should then display the amount of the discount (if any) and the
total amount of the purchase after the discount.
Reference:
(1) Starting out with Python, Third Edition, Tony Gaddis Chapter 3
(2) https://youtu.be/0qHWyPWhZO4
"""
# given a package retails
package_price = 99
# Get the User Input(the number of packages purchased) and Convert to int
number_of_packages = int(input("Please Enter the number of packages"+\
"purchased : "))
# check All the conditions
if number_of_packages < 10:
discount = 0
elif number_of_packages < 20:
discount = 0.1 # 0.1 is 10%
elif number_of_packages < 50:
discount = 0.2 # 0.2 is 20%
elif number_of_packages < 100:
discount = 0.3 # 0.3 is 30%
else:
discount = 0.4 # 0.4 is 40%
# Calculate the discount amount and total amount
sub_total = number_of_packages * package_price
discount_amount = sub_total * discount
total_amount = sub_total - discount_amount
# Display the Result
print("the amount of the discount is : $" + \
format(discount_amount, ",.2f"))
print("total amount of the purchase after the discount is : $" + \
format(total_amount, ",.2f"))