
program an interface for a futuristic vending machine that serves users hot food and drinks. Users enter input in from a numerical keypad that also contains a handful of letters. The customer will receive a menu and a prompts asking for their selection.
The vending machine needs to keep track of a few things: The customerâ��s order, which consists: 1) entree 2) drink It will need to calculate the orderâ��s total cost. After the entree and the drink is selected, the machine will repeat the order to the customer and display the total price. Step 1: Create a class to keep track of the customerâ��s order. Provide getters and setters for the entr�©e and drink. Provide a method that calculates the total of the order Provide a method that prints the Entree menu Provide a method that prints the Drink menu Provide a toString() method that returns a String in the following form: Your total for ENTEREE and DRINK is: ORDERCOST Example: Your total for salad and juice is: $2.50
Step 2: Main method & Scanner To allow users to enter input we will be using an instance of the Scanner class. The Scanner class is not a class available by default and must be imported with the import statement: import java.io.Scanner;
Step 2: Menu Prompt The first menu that is printed out for customer is the entree menu. Print this menu to the screen so customer can have a look at their choices. (Use your class method) Then following the menu, ask the customer what entree they would like to order and take in their input. Here is an example of the expected output: Entree Menu 1. Hamburger ($1.50) 2. Cheese Burger ($1.75) 3. Salad ($1.50) 4. Tacos ($1.00) 5. Hotdog ($1.00)
What entree would you like to order? 3 If they fail to enter a valid item prompt them again (use a loop) After the customer orders an entree, proceed to print out the drink menu and ask them which drink they would like to order. Here is an example of the expected output:
Drink Menu 1. Cola ($0.75) 2. Juice ($1.00) 3. Tea ($0.50) 4. Coffee ($0.50) 5. Water ($1.00)
What drink would you like to order? 2 If they fail to enter a valid item prompt them again (use a loop) After both items have been chosen, display the choices selected by the customer. The name of the items should be displayed rather than their numerical value. Ask for confirmation from the customer that this is the correct order. Ask the customer to enter ââ?¬Ë?yââ?¬â?¢ for yes and ââ?¬Ë?nââ?¬â?¢ for no. If the order is correct, display the total cost for the entree and drink. If the order in incorrect then print out to the screen, ââ?¬Å?Have a good day!ââ?¬Â? Sample Output Here's what I got when I ran my main method.
Entree Menu 1. Hamburger ($1.50) 2. Cheese Burger ($1.75) 3. Salad ($1.50) 4. Tacos ($1.00) 5. Hotdog ($1.00)
What entree would you like to order? 3
Drink Menu 1. Cola ($0.75) 2. Juice ($1.00) 3. Tea ($0.50) 4. Coffee ($0.50) 5. Water ($1.00)
What drink would you like to order? 2 Your current order is salad and juice. Is this correct (y/n)? y Your total for salad and juice is: $2.50 Have a good day! Here is an example of the final printout if I decided the order was wrong.
Your current order is salad and juice. Is this correct (y/n)? n Have a good day!
Step 3: Make the Vending machine continue until the users tell it to stop. After: ââ?¬Å?Have a Good Day!ââ?¬Â? Prompt the user to see if they wish to continue: Do you wish to order again (y/n)? If they enter ââ?¬Ë?yââ?¬â?¢ start over with the first menu. If they enter n exit the program.