PROBLEM 4   Here is the e-list for Mart 007 ------------------ Welcome ------------------ ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 5 available 2. Voice Changer ($5.5 each), 10 available 3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================   Using python, write a function named transaction() that repeatedly shows the e-list for Mart 007 to a user so that users can choose the products and the quantities they want to buy. All user inputs must be validated. At every iteration, the inventory should be updated until the user decides to quit. That means the values stored in your data structures need to be updated. Your function must use exception handling to handle all possible run-time errors so this function does not crash. Sample output: ------------------ Welcome ------------------ ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 5 available 2. Voice Changer ($5.5 each), 10 available 3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! ============================================= Select product >> 1 You have selected the Spiked Umbrella, how many would you like to buy? >> 2 2 Spiked Umbrella(s) have been selected. Current total is $14.5. ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 3 available 2. Voice Changer ($5.5 each), 10 available 3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! ============================================= Select product >> 2 You have selected the Voice Changer, how many Quantity must be a number. Please enter again Quantity must be positive. Please enter again 3 Voice Changer(s) have been selected. Current total is $31.0. ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 3 available 2. Voice Changer ($5.5 each), 7 available 3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! ============================================= would you like to buy? >> three >> -3 >> 3 Select product >> 1 You have selected the Spiked Umbrella, how many would you like to buy? >> 4 Sorry, only 3 Spiked Umbrella(s) are available in stock.   Please lower the quantity or try a different item. ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 3 available 2. Voice Changer ($5.5 each), 7 available 3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! ============================================= Select product >> 1 You have selected the Spiked Umbrella, how many would you like to buy? >> 1 1 Spiked Umbrella(s) have been selected. Current total is $38.25. ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 2 available 2. Voice Changer ($5.5 each), 7 available 3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! ============================================= Select product >> 3 You have selected the Spy Camera, how many would you like to buy? >> 2 2 Spy Camera(s) have been selected. Current total is $68.25. ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 2 available 2. Voice Changer ($5.5 each), 7 available 3. Spy Camera ($15.0 each), 6 available Press 4 when you are done! ============================================= Select product >> 4 Thank You!

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

PROBLEM 4

 

Here is the e-list for Mart 007

------------------ Welcome ------------------ =============================================

Please select the item you want
to buy from the following menu:

1. Spiked Umbrella ($7.25 each), 5 available 2. Voice Changer ($5.5 each), 10 available
3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================

 

Using python, write a function named transaction() that repeatedly shows the e-list for Mart 007 to a user so that users can choose the products and the quantities they want to buy. All user inputs must be validated. At every iteration, the inventory should be updated until the user decides to quit. That means the values stored in your data structures need to be updated. Your function must use exception handling to handle all possible run-time errors so this function does not crash.

Sample output:

------------------ Welcome ------------------ =============================================

Please select the item you want
to buy from the following menu:

1. Spiked Umbrella ($7.25 each), 5 available 2. Voice Changer ($5.5 each), 10 available
3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================

Select product >> 1
You have selected the Spiked Umbrella, how many would you like to buy? >> 2

2 Spiked Umbrella(s) have been selected.

Current total is $14.5. =============================================

Please select the item you want
to buy from the following menu:
1. Spiked Umbrella ($7.25 each), 3 available 2. Voice Changer ($5.5 each), 10 available
3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================

Select product >> 2
You have selected the Voice Changer, how many Quantity must be a number. Please enter again Quantity must be positive. Please enter again

3 Voice Changer(s) have been selected.

Current total is $31.0. =============================================

Please select the item you want
to buy from the following menu:
1. Spiked Umbrella ($7.25 each), 3 available 2. Voice Changer ($5.5 each), 7 available
3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================

would you like to buy? >> three >> -3
>> 3

Select product >> 1
You have selected the Spiked Umbrella, how many would you like to buy? >> 4 Sorry, only 3 Spiked Umbrella(s) are available in stock.

 

Please lower the quantity or try a different item. =============================================

Please select the item you want
to buy from the following menu:

1. Spiked Umbrella ($7.25 each), 3 available 2. Voice Changer ($5.5 each), 7 available
3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================

Select product >> 1
You have selected the Spiked Umbrella, how many would you like to buy? >> 1

1 Spiked Umbrella(s) have been selected.

Current total is $38.25. =============================================

Please select the item you want
to buy from the following menu:
1. Spiked Umbrella ($7.25 each), 2 available 2. Voice Changer ($5.5 each), 7 available
3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================

Select product >> 3
You have selected the Spy Camera, how many would you like to buy? >> 2

2 Spy Camera(s) have been selected.

Current total is $68.25. =============================================

Please select the item you want
to buy from the following menu:
1. Spiked Umbrella ($7.25 each), 2 available 2. Voice Changer ($5.5 each), 7 available
3. Spy Camera ($15.0 each), 6 available Press 4 when you are done! =============================================

Select product >> 4
Thank You!
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Risks related to security
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
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