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).

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 15RQ
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning