Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 Trish at Bargain Used Books continues to use the programs you developed for her. You expect that at some point, Trish will ask

image text in transcribed

Problem 1

Trish at Bargain Used Books continues to use the programs you developed for her. You expect that at some point, Trish will ask you to extend the types of items that she currently sells. So you've decided to update the program you did for Lab 03 to use functions.

You will be rewriting Lab03P3.py to use functions. Your updated program will not change what the program does, but it will make it easier to enhance.

The instructor has provided a file called Lab05P1-FillThisIn.py. Download that file and rename it Lab05P1.py.

Copy that file into your PyCharm project.

Change the program header to include your name and the date.

The partial program is made up of 4 functions:

main - DO NOT CHANGE ANY OF THE CODE IN THIS FUNCTION.

This function is already complete. It calls the other 3 functions to accomplish its work:

The main function calls get_item_count and then get_item_total 3 times to get the item costs for workbooks, textbooks, and magazines.

Then the main function calls calc_and_display_receipt to print the receipt.

get_item_count

This function will need to be implemented.

This function takes one parameters:

max_allowed maximum number of items the user can enter

The function will ask the user to enter the number of items. If the user enters less than 0 or more than the max allowed, an error message will be printed and they will be asked to enter a different value. See the sample output for an example.

The function will return the number of items the user enters.

HINT: This function is only asking about a SINGLE item type. It might be the workbooks, textbooks, magazines, or something else. Notice the prompt to the user just asks for an ITEM, not a specific item type. The solution the instructors came up with has only 5 lines of code in the implementation for this function. If you have more than that, you may not be implementing this function correctly.

get_item_total

This function will need to be implemented.

This function takes two parameters:

num_items number of items

unit_price the cost of each item

The function calculates the total cost for the items and returns that value.

calc_and_display_receipt

This function will need to be implemented.

This function takes three parameters:

wb_total total cost of workbooks

tb_total total cost of textbooks

m_total total cost of magazines

The function will calculate the total before tax.

The function will calculate the sales tax using the function you created. Use the provided global constant for the sales tax.

The function will calculate the total after tax.

Then the function will print a receipt that contains the following information:

Total cost of workbooks (if zero, skip this step)

Total cost of textbooks (if zero, skip this step)

Total cost of magazines (if zero, skip this step)

A divider line

Subtotal before tax

Amount of tax to be charged

Total including tax

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions