Project #4 is a re-writing of Project #2. However, it will now use functions. There are no changes to logic of the program. In other words, donot modify any of the existing code(see the requirements below). The content to complete this assignment is in Chapters(Think Python) 1,2,3,5,6,7(No recursion) and the slides. 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 20% 20-49 30% 50-99 40% 100 or more 50% Design a program that asks the user 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. New Requirements: Modify Project #2 and convert the respective logic/tasks in the existing program(Project #2) to use functions and modules/Python files. The logic below should be placed/converted to functions: o Get the quantity o Determining the discount o Calculating the full price o Calculate discount o Calculate the total amount o Printing of the total amount and discount amount The only logic/code in main() should be user-defined function calls. There should be at least two modules o The modules/Python files below will be importing into your program. o The first module/Python file will contain the $99.00 retail price which is used as a global constant. o The second module/Python file will contain a “Welcome Shoppers ” heading. An example is below. The heading below needs to contained in its Module and importing into the main source file(.py). Welcome Shoppers. Below is the discount on the product based on the amount you buy: Quantity of 100 or more: 50% discount Quantity of 99-50 items: 40% discount Quantity of 49-20 items: 30% discount Quantity of 19-10 items: 20% discount No discount if it is under 9 items
Project #4 is a re-writing of Project #2. However, it will now use functions. There are no changes
to logic of the program. In other words, donot modify any of the existing code(see the
requirements below). The content to complete this assignment is in Chapters(Think Python)
1,2,3,5,6,7(No recursion) and the slides.
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 20%
20-49 30%
50-99 40%
100 or more 50%
Design a program that asks the user 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.
New Requirements: Modify Project #2 and convert the respective logic/tasks in the existing
program(Project #2) to use functions and modules/Python files.
The logic below should be placed/converted to functions:
o Get the quantity
o Determining the discount
o Calculating the full price
o Calculate discount
o Calculate the total amount
o Printing of the total amount and discount amount
The only logic/code in main() should be user-defined function calls.
There should be at least two modules
o The modules/Python files below will be importing into your program.
o The first module/Python file will contain the $99.00 retail price which is used as a
global constant.
o The second module/Python file will contain a “Welcome Shoppers ” heading. An
example is below. The heading below needs to contained in its Module and
importing into the main source file(.py).
Welcome Shoppers.
Below is the discount on the product based on the amount you buy:
Quantity of 100 or more: 50% discount
Quantity of 99-50 items: 40% discount
Quantity of 49-20 items: 30% discount
Quantity of 19-10 items: 20% discount
No discount if it is under 9 items
Solution: required code has been provided below along with the output. Comments have been placed in the code to depict the functionality.
Module 1 : for retail price (retail.py)
global retailprice retailprice = 99
Module 2: Welcome message (welcome.py)
welcome_msg = """Welcome Shoppers. Below is the discount on the product based on the amount you buy: Quantity of 100 or more: 50% discount Quantity of 99-50 items: 40% discount Quantity of 49-20 items: 30% discount Quantity of 19-10 items: 20% discount No discount if it is under 9 items"""
Step by step
Solved in 3 steps