Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Scenario: 1. The program uses a loop to repeatedly get an item from the user. This should be in the global code section

Lab Scenario: 1. The program uses a loop to repeatedly get an item from the user. This should be in theSubmission: 1. All submissions will be via Blackboard. Please see assignment in this module. 2. Your accepted

Lab Scenario: 1. The program uses a loop to repeatedly get an item from the user. This should be in the "global code" section of the file. 2. On each iteration of the loop, the program ask the user for the following: a. the item name b. if the item is a food item c. if it's not a food item, ask if it's a medicine item d. the item price 3. Based on the user responses, the program will compute the tax for the item using a tax() function you write. The tax function should have parameters for price and category. Category may be 'food', 'medicine', or 'general'. The category parameter should default to 'general'. The tax() function should return: a. price* .025 when the category is 'food' (tax on food is 2.5%) b. O when the category is 'medicine' (there is no tax on medicine) c. price*.06 when the category is 'general' (tax on other items is 6%) 4. The program should maintain a list named receipt where each entry in the list is a list or tuple containing an item name, price, and extended price (meaning the price plus the tax). After you have gotten all input for an item, add a new entry to receipt for that item. 5. After adding the entry to receipt, prompt for whether the user would like to enter another item. If so, execute the loop body again. 6. When the user indicates they do not want to enter any more items, call a print_receipt() function to print a nicely-formatted receipt. This function should take one parameter of the type described for receipt above. The printed receipt should contain a header with the headings 'Item', 'Price', and 'Extended Price'. Under the header, each row should list the item name, price, and extended price for a single item, formatted as nicely as you can. (Use a for loop to iterate through each entry in the big list and print the row for that entry.) After all items are printed, leave a blank line and then print 'Total', followed by the total of all extended prices, lined up as well as you can under the individual item extended prices. (Note that all prices and extended prices should be printed with dollar signs and exactly two decimal places.) 7. For this lab, you are expected to define at least the following two user-defined functions. You may define additional functions if you wish, but you must include and use at least these two, as described above: a. tax(): see #3 above b. print_receipt(): see #6 above Submission: 1. All submissions will be via Blackboard. Please see assignment in this module. 2. Your accepted sources for obtaining help: module resources, textbook, course instructor and GTA 3. The code needs to be written in the firstname_lastname_LA5.py template file. Please change the name of the file and the header of the file. Example File name: Jane_Doe_LA5.py Sample input/output: *** Thank you for using self-checkout *** Enter item name: water Is this a food item? (y/n): y Enter price: $2 Enter another item? (y/n): y Enter item name: aspirin Is this a food item? (y/n): n Is this a medicine item? (y/n): y Enter price: $11.99 Enter another item? (y/n): y Enter item name: tissues Is this a food item? (y/n): n Is this a medicine item? (y/n): n Enter price: $3.99 Enter another item? (y/n): n Item Price water $2.00 aspirin $11.99 tissues $3.99 Total Extended Price $2.05 $11.99 $4.23 $18.27

Step by Step Solution

3.45 Rating (164 Votes )

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Explain how religious attitudes affect firm behavior.

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

Define Management by exception

Answered: 1 week ago