Question
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.
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.
Create a file named Lab01P4.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.
- 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.
NOTE: Your program code should implement these steps IN THE SAME ORDER as listed above.
All monetary values should be output with a precision of 2 digits after the decimal point. You should use what was presented in this lesson to achieve that result.
----------------------------------------------------------
Sample Output:
Enter the number of paperback books: 3
Enter the number of hardback books: 2
Enter the number of magazines: 4
Cost before tax: $37.30
Sales tax: $2.61
Cost after tax: $39.91
-------------------------------------------
In your program, besides the header comment, add three additional comments:
- A comment that identifies where the input steps begin
- A comment that identifies where the processing steps begin
- A comment that identifies where the output steps begin.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started