Consider a vending machine
Java.
Consider a vending machine that offers the following options:
[1] Get gum
[2] Get chocolate
[3] Get popcorn
[4] Get juice
[5] Display total sold so far
[6] Quit
Design and implement a program that continuously allows users to select from
these options. When options 1–4 are selected an appropriate message is to be
displayed acknowledging their choice. For example, when option 3 is selected the
following message could be displayed: Here is your popcorn
When option 5 is selected, the number of each type of item sold is displayed. For
example:
3 items of gum sold
2 items of chocolate sold
6 items of popcorn sold
9 items of juice sold
When option 6 is chosen the program terminates. If an option other than 1–6 is
entered an appropriate error message should be displayed, such as:
Error, options 1-6 only!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps