Question: Write a program that simulates a vending machine. The program should display the message This is a vending machine - What is your selection? Then

Write a program that simulates a vending machine. The program should display the message "This is a vending machine - What is your selection?" Then display the following menu.
1a - chocolate bar -15 cents
1b - potato chips -10 cents
2a - popcorn -15 cents
2b - sweet tarts -25 cents
Then display the message "Enter a coin:". This could be 1,5,10, or 25.
If the user entered the exact amount, then display message - "Here is the "
If the user entered more than required, then display message - "Here is the and your change is "
If the user entered less than what is required, then display message - "Sorry, not enough money"
Compile and test your code. Submit your .java file through Blackboard.
Notes:
For the selection the user only enters 1a,1b,2a, or 2b.
is what the user selected.
is change from the coin that was entered.
Attach File

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!