
Need help with question. Sample output below. Coding language is python.
Copy your solution from the question 1 into a new file and name it a2_q2.py. You must not overwrite your previous solution; the marking TA will want to see both files. You will add code to this new file (a2_q2.py) that allows the following functionalities. The user (customer) can now view the e-list to select items for purchase.
They should be able to select the items by entering the corresponding number from the list. Again, invalid selections should be handled with suitable error messages and the list 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 to buy. 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 is made, the current total should be printed, and the stock should be updated on the e-list (see sample outputs below).
When the user completes product selection (i.e., enters 4), it should provide the user with their
receipt. The receipt must show (a) the subtotal, (b) tax amount (13% of the subtotal) and (c) the
total cost of the purchase. See sample outputs below.
Sample output (how it should look like):
Please enter your name >> Bond
Hi Bond, please enter your company name >> Mart 007
Let's setup a sales menu for 'Mart 007'.
Enter item 1's name >> Spiked Umbrella
Enter item 1's unit price >> 7.25
Enter item 1's quantity >> 5
Enter item 2's name >> Voice Changer
Enter item 2's unit price >> 5.5
Enter item 2's quantity >> 10
Enter item 3's name >> Spy Camera
Enter item 3's unit price >> fifteen
Price must be a number. Please enter again >> -15
Price must be positive. Please enter again >> 15
Enter item 3's quantity >> eight
Stock must be a number. Please enter again >> -8
Stock must be positive. Please enter again >> 8
Great!
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
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 would you like to buy? >> three
Quantity must be a number. Please enter again >> -3
Quantity must be positive. Please enter again >> 3
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!
=============================================
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!
Here is your invoice!
=============================================
1. Spiked Umbrella x 3 21.75
2. Voice Changer x 3 16.50
3. Spy Camera x 2 30.00
------------------------------------
Subtotal: 68.25
Tax: 8.87
------------------------------------
Total: 77.12

Step by stepSolved in 3 steps with 3 images

- >> classicVinyls.cpp For the following program, you will use the text file called “vinyls.txt” attached to this assignment. The file stores information about a collection of classic vinyls. The records in the file are like the ones on the following sample: Led_Zeppelin Led_Zeppelin 1969 1000.00 The_Prettiest_Star David_Bowie 1973 2000.00 Speedway Elvis_Presley 1968 5000.00 Spirit_in_the_Night Bruce_Springsteen 1973 5000.00 … Write a declaration for a structure named vinylRec that is to be used to store the records for the classic collection system. The fields in the record should include a title (string), an artist (string), the yearReleased (int), and an estimatedPrice(double). Create the following…arrow_forwardPython S3 Get File In the Python file, write a program to get all the files from a public S3 bucket named coderbytechallengesandbox. In there there might be multiple files, but your program should find the file with the prefix and cb - then output the full name of the file. You should use the boto3 module to solve this challenge. You do not need any access keys to access the bucket because it is public. This post might help you with how to access the bucket. Example Output ob name.txt Browse Resources Search for any help or documentation you might need for this problem. For exampler array indexing, Ruby hash tables, etc.arrow_forwardwrite in c++Write a program that would allow the user to interact with a part of the IMDB movie database. Each movie has a unique ID, name, release date, and user rating. You're given a file containing this information (see movies.txt in "Additional files" section). The first 4 rows of this file correspond to the first movie, then after an empty line 4 rows contain information about the second movie and so forth. Format of these fields: ID is an integer Name is a string that can contain spaces Release date is a string in yyyy/mm/dd format Rating is a fractional number The number of movies is not provided and does not need to be computed. But the file can't contain more than 100 movies. Then, it should offer the user a menu with the following options: Display movies sorted by id Display movies sorted by release date, then rating Lookup a release date given a name Lookup a movie by id Quit the Program The program should perform the selected operation and then re-display the menu. For…arrow_forward
- Load the airline JSON file into a python dictionary, save it to a text file and print the airlines that operated in Boston and SanFrancisco airports during the month of June.arrow_forwardCase Problems - 1- In Chapter 8, you modified the EventDemo program for Carly’s Catering to accept and display data for an array of three Event objects. Now, modify the program to use an array of eight Event objects. Prompt the user to choose an option to sort Events in ascending order by event number, number of guests, or event type. Display the sorted list, and continue to prompt the user for sorting options until the user enters a sentinel value. Save the file as EventDemo.java.arrow_forward1. Using the code below, create a function called outputOrderRow() that has the following signature: function outputOrderRow($file, $title, $quantity, $price) { } 2. Implement the body of the outputOrderRow() function. It should echo the passed information as a table row. Use the number_format() function to format the currency values with two decimal places. Calculate the value for the amount column.arrow_forward
- Please give correct code. Thanksarrow_forwardFilename: runlength_decoder.py Starter code for data: hw4data.py Download hw4data.py Download hw4data.pyYou must provide a function named decode() that takes a list of RLE-encoded values as its single parameter, and returns a list containing the decoded values with the “runs” expanded. If we were to use Python annotations, the function signature would look similar to this:def decode(data : list) -> list: Run-length encoding (RLE) is a simple, “lossless” compression scheme in which “runs” of data. The same value in consecutive data elements are stored as a single occurrence of the data value, and a count of occurrences for the run. For example, using Python lists, the initial list: [‘P’,‘P’,‘P’,‘P’,‘P’,‘Y’,‘Y’,‘Y’,‘P’,‘G’,‘G’] would be encoded as: ['P', 5, 'Y', 3, ‘P’, 1, ‘G’, 2] So, instead of using 11 “units” of space (if we consider the space for a character/int 1 unit), we only use 8 “units”. In this small example, we don’t achieve much of a savings (and indeed the…arrow_forwardUSE THE SIMPLE PYTHON CODE PLEASE The username code. The company can choose the specific criteria for the username. The criteria is as follows: a minimum length, a minimum number of capital letters, and a minimum number of special characters. Special charters are [$, #, ^, %, . etc]. You will turn in three .py files. The first file called main.py contains your main interface. The second file called functions.py contains all the functions your main code. The third file called parameters.py contains the parameters of the code: the special character list, the minimum length, the minimum number of special characters, the minimum number of capital letters, and the number of tries the user gets to input user name. Your code operates as follows. Display the criteria for the username. Prompt the user to input a username. If the username does not meet criteria, tell the user why and re prompt to enter in a username. Repeat until you reach the maximum number of tries allowed.arrow_forward
- The average amount Sold function is not run as expect. Please fix it. The input file: sales.txt header in picture. It is over 5000 char. I can't copy. 13492785 2017 Jane North; 1000 78534520 2012 Tim South; 95020192756 2017 Linda East; 15000 19273458 2012 Paul West; 500078520192 2017 Mary Jane Doe; 5001 32278520 2012 Victor Smith; 799514278520 2012 Mary Johnson; 12056192785 2017 Tom Baker; 1300 88278529 2012 Diana Newman; 150089278527 2012 William Peterson; 1420098278528 2012 Jim Gaddis; 120099192785 2017 Laura King; 1000 43278524 2012 Ann McDonald; 2000 The output expect: in picture. #include "Sales.h"#include <iostream>#include <sstream>#include <iomanip>#include <fstream>#include <string>using namespace std; const int MAX_SIZE = 30; void readData(string fileName, Sales salesArr[], int n);double calcSalesAvg(Sales salesArr[], int n);void displayOverAvg(Sales salesArr[], int n, double avg);void writeReport(Sales salesArr[], int n, string…arrow_forwardWrite a stored procedure named displayCountryMessage(). The displayCountryMessage () should receive one input argument for the country name and then based on that input argument, display a short message and the name of the country. Otherwise, if the country does not exist in the country table, then the procedure should display an appropriate message. For example, if I call the displayCountryMessage() procedure and pass it “France”, then it will display the message “France exists in the Country table”. If I call the displayCountryMessage()procedure and pas it “AAAAA”, then it will display the message “AAAAA does NOT exist in the Country table”.arrow_forward3. Which among the following shows a valid use of the Direction enumeration as a parameter to the moveCharacter function? Select al that apply. enum Direction { case north, south, west, east}func moveCharacter(x: Int, y: Int, facing: Direction) {// code here} moveCharacter(x: 0, y: 0, facing: .southwest) moveCharacter(x: 0, y: 0, facing: Direction.north) moveCharacter(x: 0, y: 0, facing: .south) moveCharacter(x: 0, y: 0, facing: Direction.northeast)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





