Question: Question: Write a program that simulates a snack vending machine. - lets set the initial quantity of each item to 10. - Each time the

Question: Write a program that simulates a snack vending machine.

- lets set the initial quantity of each item to 10.

- Each time the program runs, it should enter a loop that performs the following steps:

-displays the item name and its price.

-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

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!