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).
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
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F08b27964-f736-48a1-b0ab-3bda23629c3c%2Fa3c4ab13-ccbc-4d1d-b505-03582782877b%2Fvrv9r8b_processed.png&w=3840&q=75)
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==](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F08b27964-f736-48a1-b0ab-3bda23629c3c%2Fa3c4ab13-ccbc-4d1d-b505-03582782877b%2Fuumb4zr_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education