Provide a method that calculates the total of the order Provide a method that prints the Entree
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.
View Answers
Related Tutorials/Questions & Answers:
String fromCharCode() method example in Action Script3
.style1 {
font-size: medium;
}
String fromCharCode()
method example in Action Script3:-
String
provide a
method to find characters by the character code using fromCharCode()
method. we have define a string using this
method Advertisements
method method how and where, we can define methods ?
can u explain me with full programme and using comments
methodmethod can you tell me how to write an abstract
method called ucapan() for B2 class
class A2{
void hello(){
system.out.println("hello from A2");
}}
class B2 extends A2{
void hello(){
system.out.println("hello from B2
ModuleNotFoundError: No module named 'provide'ModuleNotFoundError: No module named '
provide' Hi,
My Python... '
provide'
How to remove the ModuleNotFoundError: No module named '
provide... to install padas library.
You can install
provide python with following command
Please provide the codePlease
provide the code
Write a program to recursively download the web pages available in the given site URL
Please provide the codePlease
provide the code
Program to find depth of the file in a directory and list all files those are having more number of parent directories
Provide the code pleaseProvide the code please
Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
Please provide the codePlease
provide the code
Create a file system:
We just have one file on the hard disk. But we can create directories, sub-directories and files in that file only
Method
Method
In this section, we will explore the concept of
method
in the reference of object oriented... and behaviors are defined by methods.
Method : An brief
introduction
Methods
Please provide the coding for this problemPlease
provide the coding for this problem Please
provide the coding for the following problem. Write a "hangman" game that randomly generates a word and prompts the user to guess one letter at a time. Each letter in the word
provide source - Java Beginnersprovide source please
provide code for this program
Write a program to download a website from a given URL. It must download all the pages from that website. It should take the depth of retrieval from the user input. All
provide me the program for that ques.provide me the program for that ques. wtite a program in java there is a class readchar.the functionality of this class is to read a string from the console and display the characters of that string on the console.
provide code - Swing AWTprovide code Dear frnds please
provide code for two player CHESS GAME.....using swings,awt concepts
Hi friend,
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public
Please provide coding for following problemPlease
provide coding for following problem Please
provide the coding for the following problem:
You will write a java program that will read data... will be the initials followed by their score in sorted
order from top score to lowest
provide example in J2ee/jsp - JSP-Servletprovide example in J2ee/jsp how to manage search options page in jsp using back end as oracle/sql?
i am using multiple search options. so please
provide code for this or tutorial
method inside the method??method inside the
method?? can't we declare a
method inside a
method in java??
for eg:
public class One
{
public static void main(String[] args)
{
One obj=new One();
One.add();
private static void add
To provide Help Option - Java BeginnersTo
provide Help Option hi i am writing one small application there i wanted to
provide "Help" button to user.From there they will be geting how... theire own help article writen..." how we can
provide our Help writen for our
get and set method a constructor that initialises the four instance variables.
Provide a set and get
method for each instance variable. In addition
provide a
method named getInvoiceAmount that
calculates the invoice amount (i.e multiplies the quantity by the price
get method get
method how to use get
method:
secure
method is post
method and most of use post
method why use a get
method File.list() method()
method then it is working fine although s2 also
prints as "d:/java" ?? help
Here is an example of File.lsit()
method. The given code accepts the directory path in
order to display the files and directories of that directory
method questionmethod question How do I figure out the difference in a
method heading, a
method body, and a
method definition
A method getColumnCount.A
method getColumnCount. There is a
method getColumnCount in the JDBC API. Is there a similar
method to find the number of rows in a result set
Static methodStatic method what is a static
method?
Have a look at the following link:
Java Static
Method gc() methodgc() method what is difference between java.lang.System class gc()
method and java.lang.Runtime class gc()
method method namemethod name Is there any
method which is equivalent to c++'s delay(int) function
main methodmain method Why is the java main
method static
main methodmain method What is the argument type of a program's main()
method Checkbox methodCheckbox method what is the
method to check if the checkbox is checked
abstract methodabstract method Can a concrete class have an abstract
method Method overridingMethod overriding How compiler decide parent class'method or child class's
method to call?
What is the meaning of this:
Parent obj=new child_obj
finalize() methodfinalize() method Can an object's finalize()
method be invoked while it is reachable? An object?s finalize()
method cannot be invoked... finalize()
method may be invoked by other objects
_jspService() method_jspService() method Why is jspService()
method starting with an '' while other life cycle methods do not?
jspService()
method... don't override _jspService()
method in any JSP page
init methodinit method why init
method used in servlet?
The init()
method is called only once by the servlet container throughout the life of a servlet. By this init()
method the servlet get to know that it has been placed
java methodjava method can we declare a
method in java like this
static... book.
i don't understand the
static
{
}
plz help me. what kind of
method is it, what it do, what are the advantages of this kind of
method?
Answer me soon
method overloadingmethod overloading public void test(int a){}
public void test(long a){}
i will call some x.test(125)
which
method is called pls tell me
Method overridingMethod overriding can a
method declared in one package be over ridden in a different package?
A subclass in a different package can only override the non-final methods declared public or protected
method overloading method overloading public void test(int a);
pulic void test(long a);which sutiation x.long is called
recursive methodrecursive method Write a recursive
method to add the first n terms of the series
1 + (1/2) - (1/3) + (1/4) - (1/5