Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions

Question

How is a traditional bond structured?

Answered: 1 week ago

Question

4. Make recommendations on steps to take to melt the glass ceiling.

Answered: 1 week ago

Question

1. Discuss the potential legal issues that relate to training.

Answered: 1 week ago

Question

3. Design a program for preparing for cross-cultural assignments.

Answered: 1 week ago