In this problem, you are given a partially completed program, and you need to update and fill in the rest of the program to produce the desired output.
This problem is like other programs we've done for Trish's Swap Shop. The program asks the user for the number of books, DVDs, and games being purchased, and then it will output the cost for each item and the total with tax.
Values:
• Books are $2.25 each.
• DVDs are $4.35 each.
• Games are $5.00 each.
• Tax is 6.5%
Sample output:
Enter the number of books: 7
Enter the number of DVDs: 3
Enter the number of games: 4
Books: $15.75
DVDs: $13.05
Games: $20.00
Subtotal: $48.80
Tax: $3.17
Total: $51.97
• The instructor has provided a file called Lab04P2-FillThisIn.py. Download that file and rename it Lab04P2.py.
• Copy that file into your PyCharm project.
• Change the program header to include your name and the date.
• Replace # -- FILL THIS IN -- # with correct code that will enable the program to produce output like what is shown above.
• Use the function name and parameter names indicated in the program comments.
• Use Global Constants within the function where appropriate to make your code more readable.
• All monetary values should be formatted with 2 digits after the decimal point.
• Run this program using the PyCharm Terminal.
• Take a screenshot of the Terminal that includes the line showing where you started the program run with the results.
• Name the screenshot Lab04P2-ouput.jpg.# Global Constants
BOOK_PRICE =2.25
DVD_PRICE =4.35
GAME_PRICE =5.00
TAX_RATE =0.065 # Tax Rate of 6.5%
1 usage
def main(): # DO NOT CHANGE ANY CODE IN THE MAIN ROUTINE
# NOTE: This program is NOT doing input validation to simplify the
# program. To do input validation we would need to insert these lines
# into while loops.
num_books = int(input('Enter the number of books: '))
num_dvds = int(input('Enter the number of DVDs: '))
num_games = int(input('Enter the number of games: '))
calc_and_display_total (num_books, num_dvds, num_games)
# Create a function called calc_and_display_total. It should take
# 3 parameters. Use the names provided here:
# books - Number of books
# dvds - Number of dvds
# games - Number of games
#
# It should calculate and display the total cost of each item. It should also
# calculate and display the total cost with tax.
# -- FILL THIS IN -- #
main()
# Global Constants
B00K_PRICE = 2.25
DVD_PRICE= 4.35
GAME_PRICE= 5.00
10
TAX_RATE= 0.065 # Tax Rate of 6.5%
11
1usage
12
def main(): # DO NOT CHANGE ANY CODE IN THE MAIN ROUTINE
13
# NOTE: This program is NOT doing input validation to simplify the
14
# program. To do input validation we would need to insert these lines
15
# into while loops.
16
num_books = int(input(Enter the number of books:))
17
num dvds = int(input('Enter the number of DvDs: ))
18
num_games = int(input('Enter the number of games: '))
19
20
calc_and_display_total(num_books, num_dvds, num_games)
21
22 23
# Create a function called calc_and_display_total. It should take # 3 parameters. Use the names provided here: # books- Number of books
24
25
26
#
dvds- Number of dvds
27
#
games- Number of games
28
#
29
# It should calculate and display the total cost of each item. It should also
30
# calculate and display the total cost with tax.
31
32
#-- FILL THIS IN -- #
33 34
35
main()