Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

undefined Question: Write a program that simulates a snack vending machine. let's set the initial quantity of each item to 10. Each time the program

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedundefined

Question: Write a program that simulates a snack vending machine. let's set the initial quantity of each item to 10. Each time the program runs, it should enter a loop that performs the following steps: o displays the item name and its price. o the user either selects the item or quits the program if the user selects the item, he will next enter the quantity to buy and the amount of money to pay the total price o then the program displays the amount of change that would be returned if the user enters a negative value or if the user enters insufficient amount of money, a message should be displayed and the loop then repeats. if the user chooses to quit, the program should display the summary of all items left and total amount of money the machine earned for all purchase transactions. For security reason, the program will first ask the owner of the vending machine to enter a machine code. Set the machine code to 123. Only 3 attempts are allowed to enter the correct machine code. After three unsuccessful attempts, the program should terminate. - Save this file as: studentID.docx and the source code student ID.cpp in a folder and zip the folder test2_yourname_yourid.zip. Submit the zipped folder to MMLS. Use the sample runs of the program given below to create the program. as: as Sample runs : Welcome Snack Vending Machine Simulation Program Login screen Please enter machine code: 1. Run program and login prompt is displayed to enter machine code. (0.5m) Welcome Snack Vending Machine Simulation Program Login screen Please enter machine code: --->: 123 2. Enter machine code: 123 3. Main menu is displayed. (0.5m) 4. Choose option to exit. 5. Program displays purchase summary and stops. (0.5m) Main Menu Item Price 1. Super Ring 1.60 2. Mamee 0.40 3. Choki Choki 1.80 4. Apollo Biscuits 0.50 e. Exit / Summary Choose item [1|2134 or to exit]: Purchase Summary / Item Balance -- Qty Super Ring 10 | Mamee 10 Choki Choki 10 Apollo Biscuits 10 Total amount of money earned today is RM 0.80 Welcome Snack Vending Machine Simulation Program Login screen Please enter machine code: --> 123 1. Run the program and login again. 2. Enter item no. to buy. (0.5m) 3. Enter quantity. (0.5m) 4. Total price is displayed. (0.5m) 5. Enter amount to pay. (@.5m) A message and balance returned are displayed. (0.5m) 7. The screen is paused and press to continue. (0.5m) 8. Main menu is displayed again. (0.5m) 6. Main Menu Item Price 1. Super Ring 1.60 2. Mamee 8.40 3. Choki Choki 1.80 4. Apollo Biscuits 2.50 e. Exit / Summary Choose item (1|2|3|4 or to exit]: 1 Quantity: 1 Total price: 1.60 Enter amount to pay RM: 2 Please collect your purchased item and balance RMO. 40 Have a nice day and thank you. Press center> to continue. Main Menu Iten Price 1. Super Ring 1.60 2. Mamee 0.40 3. Choki Choki 1.80 4. Apollo Biscuits 0.50 0. Exit / Summary Choose item (12134 or 0 to exit): Login screen Please enter machine code: ---> 123 -- Main Menu Item Price 1. Super Ring 1.60 2. Mamee 0.40 3. Choki Choki 1.80 4. Apollo Biscuits e.se e. Exit / Summary Choose iten [1|23|4 or to exit]: 4 Quantity: 1 Total price: @.50 Enter amount to pay RM: 1 Please collect your purchased item and balance RM8.50 Have a nice day and thank you. Press center> to continue Main Menu 1. Run the program and login again. 2. Buy some items through the options 3. Choose option to exit. 4. Program displays purchase summary and stops. (10) Item Price 1. Super Ring 1.60 2. 8.40 3. Choki Choki 1.80 4. Apollo Biscuits 8.50 e. Exit / Summary Choose ites [1|23|4 or a to exit]: 3 Quantity: 1 Total price: 1.80 Enter amount to pay RM: 2 Please collect your purchased ites and balance RM0.20 Have a nice day and thank you. Press center> to continue - Main Menu Item Price 1. Super Ring 1.60 2. Mamee 3. Choki Choki 1.89 4. Apollo Biscuits 8.50 e. Exit / Summary Choose item [1|2|3|4 or to exit]: ----- Purchase Summary / Item Balance .. Qty Super Ring 1e Mamee 1e Choki Choka 9 Apollo Biscuits 9 Total amount of money earned today is RM 2.30 Welcome Snack Vending Machine Simulation Program Login screen Please enter machine code: --->: 123 1. Run the program and login again. 2. Enter item no. to buy. 3. Enter quantity. 4. If the quantity entered is insufficient, a message "Sorry, insufficient item! / Invalid no. Try again. is displayed. (1m) 5. The program asks you to enter quantity again. (0.5m) Main Menu Item Price 1. Super Ring 1.60 2. Mamee 0.40 3. Choki Choki 1.80 4. Apollo Biscuits 0.50 0. Exit / Summary Choose item [1|2|3|4 or to exit]: 2 Quantity: 12 Insufficient item! / Invalid no.! Try again. Quantity: Welcome Snack Vending Machine Simulation Program Login screen Please enter machine code: --->: 123 1. Run the program and login again. 2. Enter item no. to buy. 3. Enter quantity. 4. If negative number is entered in quantity, a message "Sorry, insufficient iteml / Invalid no. Try again." is displayed. (0.5) 5. The program asks you to enter quantity again. (0.5m) Main Menu Item Price 1. Super Ring 1.60 2. Mamee 0.40 3. Choki Choki 1.80 4. Apollo Biscuits 0.50 0. Exit / Summary Choose item (1|23|4 or to exit]: 2 Quantity: 12 Insufficient item! / Invalid no.! Try/sain. Quantity: 3 Insufficient item! / Invalid no.! Try again. Quantity: Welcome Snack Vending Machine Simulation Program ---- Login screen Please enter machine code: ---> 123 1. Run the program and login again. 2. Enter Item no. to buy. 3. Enter quantity. 4. Total price is displayed. 5. Enter amount to pay. 6. If the amount paid is insufficient or negative number is entered, a message "Sorry, insufficient money. is displayed. (1m) 7. The program asks you to enter amount again, (0.5m) Main Menu Item Price 1. Super Ring 1.60 2. Manee 0.40 3. Choki Choki 1.80 4. Apollo Biscuits 0.50 . Exit / Summary Choose item [1|2|3|4 or to exit]: 3 Quantity: 2 Total price: 3.60 Enter amount to pay RM: 3 Sorry, insufficient money. Enter amount to pay: -5 Sorry, insufficient money. Enter amount to pay: 5 Please collect your purchased item and balance RM1.40 Have a nice day and thank you. Press center> to continue. Welcome Snack Vending Machine Simulation Program --- Login screen Please enter machine code: --->: 123 1. Run the program and login again. 2. At the main menu, if option chosen is invalid, a message "Sorry, Invalid option." is displayed. (0.5m) 3. The program allows you to try again. (8.5m) Main Menu Iten Price 1. Super Ring 1.60 2. Maree 0.40 3. Choki Choki 1.80 4. Apollo Biscuits 0.50 0. Exit / Summary Choose item [1|2|3|4 or to exit]: 5 Sorry, Invalid option. Choose item [1|2|3|4 or to exit]: 6 Sorry, Invalid option. Choose iten (1121314 or to exit]: 7 Sorry, Invalid option. Choose item (1121314 or to exit): Welcome Snack Vending Machine Simulation Program ----- Login screen Please enter machine code: 1. At the login screen, if you enter incorrect machine code for 1" attempt, the program displays a message "Login Failed. Attempt 1 of 3" is displayed. (0.5m) 2. The program will ask you to try again. --->: 12 Login Failed. Attempt 1 of 3 Please re-enter machine code: Welcome Snack Vending Machine Simulation Program Login screen ---- Please enter machine code: ---> 12 1. If you enter incorrect machine code for 2nd attempt, the program displays a message "Login Failed. Attempt 2 of 3" is displayed. (0.5m) 2. The program will ask you to try again. Login Failed. Attempt 1 of 3 Please re-enter machine code: ---> 3 Login Failed. Attempt 2 of 3 Please re-enter machine code: Welcome Snack Vending Machine Simulation Program Login screen Please enter machine code: ---> 12 1. If you enter incorrect machine code for 3 attempt, the program displays a message "Login Failed. Attempt 3 of 3. Program is terminated after 3 failed login attempts" is displayed. (in) Login Failed. Attempt 1 of 3 Please re-enter machine code: ---> 3 Login Failed. Attempt 2 of 3 Please re-enter machine code: ---> 453 Login Failed. Attempt 3 of 3 Program is terminated after 3 failed login attempts

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions