Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM 3 Trish at Bargain Swap Shop has been using the programs you developed for her and really likes them. Recently however, she hired a

PROBLEM 3
Trish at Bargain Swap Shop has been using the programs you developed for her and really likes them. Recently however, she hired a new cashier who isn't very good at data entry. In particular, she needs the program to catch data entry errors that are made and give the user a chance to reenter the data.
To help her out, you'll be taking the first program you developed for her (Lab 01 Problem 4) and rewrite it so that it blocks out some data entry errors. Here's the changes that she'd like to see:
A user should never be able to enter a negative number for the number of books, DVDs, or games that are being purchased. Zero is a valid entry.
It is extremely rare that someone buys a LOT of a particular item, so Trish wants the program to limit the number of each item type someone can purchase. These are the limits she wants to set:
o Books: Maximum of 30
o DVDs: Maximum of 15
o Games: Maximum of 10
Other than these checks on the data entry, the program should execute as it did before.
NOTE: We are not handling issues where a user types an invalid integer, that is, an entry which cannot be converted using the int() function. We will handle that in a future lab.
The costs of each item type are the same as in Lab 01:
Books are $2.25 each.
DVDs are $4.35 each.
Games are $5.00 each.
Create a file named Lab03P3.py. Write a program that calculates the cost for the total purchase:
Ask the user to enter the number of workbooks, textbooks, and magazines being purchased.
If the user enters a negative number, or goes above the maximum for a particular item, the program should continue to ask the user to enter a number until it is valid.
Calculate the total before tax.
Calculate the amount of sales tax on the total. (Tax is 6.5%.)
Calculate the total after tax.
Output the total before tax, the sales tax, and the total after tax.
Sample Output:
Enter the number of books: -10
Number of books must be between 0 and 30.
Enter the number of books: 60
Number of books must be between 0 and 30.
Enter the number of books: 10
Enter the number of DVDs: 18
Number of DVDs must be between 0 and 15.
Enter the number of DVDs: 5
Enter the number of games: -3
Number of games must be between 0 and 10.
Enter the number of games: -2
Number of games must be between 0 and 10.
Enter the number of games: 3
Cost before tax: $59.25
Sales tax: $3.85
Cost after tax: $63.10
Remember to format monetary amounts with 2 digits after the decimal.
NOTE: There are no discounts in this program.
Hint: If you need help with validating user input, review section 4.6 in your textbook.
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 Lab03P3-ouput.jpg.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions