Menu

(Solved) : Write Program Simulates Vending Machine Vending Machine Sells Three Types Food 1 Potato Ch Q44036723 . . .

Write a program that simulates a vendingmachine.           

The vending machine sells three types of food: 1) Potato chips$1.25; 2) Cookies $0.85; 3) Candies $0.95. The program will promptfor the buyer to enter the amount in quarters (25 cents), dimes (10cents), and nickels (5 cents). The program will then present aselection menu for the foods. The buyer makes a selection. If thebuyer selects a food that is sold out, the program will display amessage and re-display the selection menu. If the buyer has put inenough money, the selected food will be dispensed, with a message”Please take a your (food)”. If the amount is more than the cost,an appropriate amount of change (in quarter, dime or nickel) willbe dispensed.

Every food is initialized with a quantity. The quantity isreduced by one every time the food is dispensed. When the quantityof a food is 0, no more should be sold, with an error stating “Soldout. Please make another choice”.

Note:

1 dollar = 4 quarters = 10 dimes = 20 nickels
1 dollar = 100 cents
1 quarter = 25 cents
1 dime = 10 cents
1 nickel = 5 cents

Requirements

Please do all of the following:

Create a Java source code file named VendingMachine.java. Makesure the file compile correctly.

3. Test your program with the following test cases:
3.1. Buyer selects a food that is available, with exact amount asthe price;
3.2 Buyer selects a food that is in stock, with less money than theprice;
3.3 Buyer selects a food that is in stock, with more money than theprice;
3.4 Buyer selects a food that is sold out;
3.5 Buyer selects a food that does not exist.
Repeat the test cases for all the foods. Capture the interactionsand save in a file.

Expert Answer


Answer to Write a program that simulates a vending machine. The vending machine sells three types of food: 1) Potato chips $1.25; …

OR