Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Problem 3

Trish at Bargain Used Books 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 paperbacks, hardbacks, or magazines 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:
    • Paperbacks: Maximum of 50
    • Hardbacks: Maximum of 20
    • Magazines: Maximum of 35

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.

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 paperbacks, hardbacks, 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.
  • Calculate the total after tax.
  • Output the total before tax, the sales tax, and the total after tax.
  • Remember to format monetary amounts with 2 digits after the decimal.

    NOTE: There are no discounts in this program.

Information to use for this problem from Lab 01 Problem 4:

Trish at Bargain Used Books has hired you to write a Python program that will help her calculate what a customer should pay. She has a very simple price structure:

Paperback books are $2.50 each.

Hardback books are $7.00 each.

Magazines are $3.95 each.

With every purchase, Trish also must charge 7% sales tax on the total.

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_2

Step: 3

blur-text-image_3

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions