Using Java
Exercise 1: Switch statement
In this exercise, we will create a fake vending machine using a switch statement. First, the program prompts the user to enter either 1, 2, or 3 to get an egg, a bottle of water, or a bag of broccoli. If the user enters 1, the program prints that it drops an egg. If the user enters 2, the program prints that it drops a bottle of water. If the user enters 3, the program prints that it drops a bag of broccoli. If the user enters a number that's not 1, 2, or 3, the program prints a help message.
Please check the following video for what exactly the program should do for different user inputs.
lab10_exercise1_demo.mp4
Run: Lab10_1 "C:\Program Files\Java\jdk-14.0.2\bin\java.exe" --javaagent:C:\Program Files\JetBrains\Welcome to our free healthy vending machine!! The available products are: (1) boiled eggs (2) bottled water (3) bags of broccoli. Type 1, 2, or 3 to choose.
clang...clang...dropping a fake egg!
Process finished with exit code 0
00:05
00:25.100x *