The user should make their selection by entering the corresponding number. It is possible that the user will enter any type of data, including text, floating point numbers, negative numbers, etc.. Invalid selections should be handled with a suitable error messages and the menu should be repeated (see sample outputs below). Once the customer has selected a product, the program should ask how many of that product the customer would like. Your program must make sure that selected products are available in stock, otherwise it should generate error messages and the menu should be repeated. After every valid selection current total should be printed and the stock should be updated (see sample outputs below). Following this, the program will ask whether the user wants to continue and see the invoice, or cancel the transaction. If user wants to continue it should provide the user with their receipts (subtotal, tax (13% of the subtotal) and the total cost of the order). Otherwise it should print a message and terminates (see sample outputs below).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

help, I need answers for my assignment 

Problem 2 (Using the menu and printing an invoice)
Write a program called a2_p2.py where you will modify your code from Problem 1 so that
customers can select products from the menu. Copy your solution from the previous part into
the new file (a2_p2.py). Do not overwrite your previous solution, as the TAs will want to see
them both.
The user should make their selection by entering the corresponding number. It is possible that the
user will enter any type of data, including text, floating point numbers, negative numbers,
etc.. Invalid selections should be handled with a suitable error messages and the menu should
be repeated (see sample outputs below). Once the customer has selected a product, the program
should ask how many of that product the customer would like. Your program must make sure that
selected products are available in stock, otherwise it should generate error messages and the menu
should be repeated. After every valid selection current total should be printed and the stock should
be updated (see sample outputs below).
Following this, the program will ask whether the user wants to continue and see the invoice, or
cancel the transaction. If user wants to continue it should provide the user with their receipts
(subtotal, tax (13% of the subtotal) and the total cost of the order). Otherwise it should print a
message and terminates (see sample outputs below).
Sample output - 1:
. it will first print the similar content as shown in the previous part and then
==========
:=========
Please select the item you want
to buy from the following menu:
1. Cake (each $2.00), 10 in stock
2. Hat (each $3.00), 7 in stock
3. Bunny (each $8.00), 3 in stock
Press 4 when you are done!
==========
===== ====
> 5
Sorry, 5 is not a valid choice! Please select from the menu.
==========
:=========
Please select the item you want
to buy from the following menu:
1. Cake (each $2.00), 10 in stock
2. Hat (each $3.00), 7 in stock
3. Bunny (each $8.00), 3 in stock
Transcribed Image Text:Problem 2 (Using the menu and printing an invoice) Write a program called a2_p2.py where you will modify your code from Problem 1 so that customers can select products from the menu. Copy your solution from the previous part into the new file (a2_p2.py). Do not overwrite your previous solution, as the TAs will want to see them both. The user should make their selection by entering the corresponding number. It is possible that the user will enter any type of data, including text, floating point numbers, negative numbers, etc.. Invalid selections should be handled with a suitable error messages and the menu should be repeated (see sample outputs below). Once the customer has selected a product, the program should ask how many of that product the customer would like. Your program must make sure that selected products are available in stock, otherwise it should generate error messages and the menu should be repeated. After every valid selection current total should be printed and the stock should be updated (see sample outputs below). Following this, the program will ask whether the user wants to continue and see the invoice, or cancel the transaction. If user wants to continue it should provide the user with their receipts (subtotal, tax (13% of the subtotal) and the total cost of the order). Otherwise it should print a message and terminates (see sample outputs below). Sample output - 1: . it will first print the similar content as shown in the previous part and then ========== :========= Please select the item you want to buy from the following menu: 1. Cake (each $2.00), 10 in stock 2. Hat (each $3.00), 7 in stock 3. Bunny (each $8.00), 3 in stock Press 4 when you are done! ========== ===== ==== > 5 Sorry, 5 is not a valid choice! Please select from the menu. ========== :========= Please select the item you want to buy from the following menu: 1. Cake (each $2.00), 10 in stock 2. Hat (each $3.00), 7 in stock 3. Bunny (each $8.00), 3 in stock
Press 4 when you are done!
> 3
No more Bunny in stock. Try something else.
====== =======
=======
> 1
How many Cake do you want? 10 in stock: 12
Not enough Cake in stock. Try a lower number.
How many Cake do you want? 10 in stock: -4
You cannot buy -4 Cake. You must enter a valid number.
How many Cake do you want? 10 in stock: 6
Your current total is: $12.00
Please select the item you want
to buy from the following menu:
1. Cake (each $2.00), 4 in stock
2. Hat (each $3.00), 2 in stock
3. Bunny (each $8.00), 0 in stock
Press 4 when you are done!
===================================
=============
============
Please select the item you want
to buy from the following menu:
> 1
How many Cake do you want? 4 in stock: 1
Your current total is: $53.00
1. Cake (each $2.00), 4 in stock
2. Hat (each $3.00), 7 in stock
3. Bunny (each $8.00), 3 in stock
Press 4 when you are done!
Please select the item you want
to buy from the following menu:
============:
============ ==
1. Cake (each $2.00), 3 in stock
2. Hat (each $3.00), 2 in stock
3. Bunny (each $8.00), 0 in stock
> 2
How many Hat do you want? 7 in stock: 5
Your current total is: $27.00
Press 4 when you are done!
========
==========
=======
!==========
Please select the item you want
to buy from the following menu:
> 4
1. Cake (each $2.00), 4 in stock
2. Hat (each $3.00), 2 in stock
3. Bunny (each $8.00), 3 in stock
Do you want to continue and see the invoice (i) or cancel the transaction (c)?
> i
Press 4 when you are done!
Your invoice is here!
===========
==========
> 3
$53.00
$6.89
Subtotal:
How many Bunny do you want? 3 in stock: 3
Your current total is: $51.00
Таx:
Total:
$59.89
=====
========
:====
Please select the item you want
to buy from the following menu:
Sample output – 2 (if 'c' was selected):
1. Cake (each $2.00), 4 in stock
2. Hat (each $3.00), 2 in stock
3. Bunny (each $8.00), 0 in stock
Do you want to continue and see the invoice (i) or cancel the transaction (c)?
Your transaction has been cancelled. Thank you for trying!
Press 4 when you are done!
==== ==D==
Transcribed Image Text:Press 4 when you are done! > 3 No more Bunny in stock. Try something else. ====== ======= ======= > 1 How many Cake do you want? 10 in stock: 12 Not enough Cake in stock. Try a lower number. How many Cake do you want? 10 in stock: -4 You cannot buy -4 Cake. You must enter a valid number. How many Cake do you want? 10 in stock: 6 Your current total is: $12.00 Please select the item you want to buy from the following menu: 1. Cake (each $2.00), 4 in stock 2. Hat (each $3.00), 2 in stock 3. Bunny (each $8.00), 0 in stock Press 4 when you are done! =================================== ============= ============ Please select the item you want to buy from the following menu: > 1 How many Cake do you want? 4 in stock: 1 Your current total is: $53.00 1. Cake (each $2.00), 4 in stock 2. Hat (each $3.00), 7 in stock 3. Bunny (each $8.00), 3 in stock Press 4 when you are done! Please select the item you want to buy from the following menu: ============: ============ == 1. Cake (each $2.00), 3 in stock 2. Hat (each $3.00), 2 in stock 3. Bunny (each $8.00), 0 in stock > 2 How many Hat do you want? 7 in stock: 5 Your current total is: $27.00 Press 4 when you are done! ======== ========== ======= !========== Please select the item you want to buy from the following menu: > 4 1. Cake (each $2.00), 4 in stock 2. Hat (each $3.00), 2 in stock 3. Bunny (each $8.00), 3 in stock Do you want to continue and see the invoice (i) or cancel the transaction (c)? > i Press 4 when you are done! Your invoice is here! =========== ========== > 3 $53.00 $6.89 Subtotal: How many Bunny do you want? 3 in stock: 3 Your current total is: $51.00 Таx: Total: $59.89 ===== ======== :==== Please select the item you want to buy from the following menu: Sample output – 2 (if 'c' was selected): 1. Cake (each $2.00), 4 in stock 2. Hat (each $3.00), 2 in stock 3. Bunny (each $8.00), 0 in stock Do you want to continue and see the invoice (i) or cancel the transaction (c)? Your transaction has been cancelled. Thank you for trying! Press 4 when you are done! ==== ==D==
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Hyperlinks
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education