program an interface for a futuristic vending machine
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:
program and Interface builderprogram and
Interface builder Hi, I'm just getting started in iPhone development,
If someone could please suggest a good criterion for when to use a nib to lay out UI elemennts and when to layout the UI elements
Advertisements
producer and concumer Interface programproducer and concumer
Interface program I need producer and concumer
Interface program
Hi Friend,
Try the following code:ADS_TO_REPLACE_1
import java.util.*;
class Multithreading {
int val;
boolean value = false
pg program in machine learningpg
program in
machine learning Hi,
I am beginner in Data Science...
program in
machine learning
Try to provide me good examples or tutorials links so that I can learn the
topic "pg
program in
machine learning". Also tell
machine learning online programmachine learning online program Hi,
I am beginner in Data Science and
machine learning field. I am searching for
the tutorials to learn:
machine learning online
program
Try to provide me good examples or tutorials links so
machine learning executive programmachine learning executive program Hi,
I am beginner in Data Science and
machine learning field. I am searching for
the tutorials to learn:
machine learning executive
program
Try to provide me good examples or tutorials
machine learning basic programmachine learning basic program Hi,
I am beginner in Data Science and
machine learning field. I am searching for
the tutorials to learn:
machine learning basic
program
Try to provide me good examples or tutorials links so
pg program in machine learning and aipg
program in
machine learning and ai Hi,
I am beginner in Data...:
pg
program in
machine learning and ai
Try to provide me good examples or tutorials links so that I can learn the
topic "pg
program in
machine learning
pg program in ai and machine learningpg
program in ai and
machine learning Hi,
I am beginner in Data...:
pg
program in ai and
machine learning
Try to provide me good examples or tutorials links so that I can learn the
topic "pg
program in ai and
machine upgrad pg program in machine learning and aiupgrad pg
program in
machine learning and ai Hi,
I am beginner in Data Science and
machine learning field. I am searching for
the tutorials to learn:
upgrad pg
program in
machine learning and ai
Try to provide me good
pg program in artificial intelligence and machine learningpg
program in artificial intelligence and
machine learning Hi,
I am... for
the tutorials to learn:
pg
program in artificial intelligence and
machine learning... the
topic "pg
program in artificial intelligence and
machine learning". Also
aws training and certification machine learning programaws training and certification
machine learning program Hi,
I am beginner in Data Science and
machine learning field. I am searching for
the tutorials to learn:
aws training and certification
machine learning
program
Try
interface interface what is the use of marking
interface InterfaceInterface Can Any one Give the exact
program explanation for
Interface in java? and want to know why they used
interface instead of multiple inheritance? Thanks in advance
An
interface is one which has abstract
interface.interface. Write short note on
interface.
Please visit the following link:
Java
Interface interfaceinterface will the
interface implements a
interface
Hi Friend,
No.
Interface can extends another
interface but cannot implements it, because
interface will not contain the implementation.
Thanks
INTERFACEINTERFACE how
interface support multiple inheritance in java
interface interface Hi
I have
interface in that
interface 3 methods are there , after some days client said that,i want to add one more method in that
interface ,so how can add 4 method so that the implemented class did not affect
interfaceinterface can we extend
interface?
Hi Friend,
Yes an
interface can be extended by other
interface like using extends keyword
interface A{
}
interface B extends A{
}
For Example:
interface IntefaceA {
void
interfaceinterface what the use of
interface?
An
interface is one... variables.Any class can
implement(inherit)the
interface and make use... is achieved by using the
interface (by implementing more than one
interface at a time
interfaceinterface What is marker
interface ??
what is its use in java programming??
is this us in programming ??Explain is implementation with code
interfaceinterface develop a library
interface which has drawbook(),returnbook()(with fine),checkstatus()
and reservebook() methods.all the methods tagged with public
interfaceinterface develop a library
interface which has drawbook(),returnbook()(with fine),checkstatus()
and reservebook() methods.all the methods tagged with public
interfaceinterface why do we need
interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can...)...the y we need
interface...THis is question often i heard from my developer
InterfaceInterface I need to implement the
interface without overriding its method and also don't use abstract class for this. How to do
interfaceinterface What is the exact use of
interface in real time scenario? some people says that
interface provides multiple inheritance. Is it true...; Through
interface, we can achieve the multiple inheritance.
Java does
InterfaceInterface 1.Create an
interface names ShapeInterface that has two... class
a.Rectangle that uses the
interface
b.Circle that uses the
interface and abstract class
interface ShapeInterface{
int l=0,b=0;
public
InterfaceInterface 1.Create an
interface names ShapeInterface that has two... class
a.Rectangle that uses the
interface
b.Circle that uses the
interface and abstract class
interface ShapeInterface{
int l=0,b=0;
public
InterfaceInterface Declare an
Interface called property containting a method compute price to compute &return the price.The inerface is to be implemented by follwaing two class
(1)Bungalow&(2)Flat
both the lasses have following
EJB remote interface EJB remote
interface
The
program given below describes the way of
creating a remote
interface in EJB. The meaning of Remote
interface in terms of
Ejb is the java source file
Java Virtual Machine Free Download
Java Virtual
Machine Free Download
The Java Virtual
Machine is required to run your java
program in your
computer. The Java Virtual
Machine software is freely downloadable from
Java Remote Interface
Java Remote
Interface
The Remote
interface identifies
interfaces whose methods may be invoked remotely from a non-local virtual
machine. Any remote object must directly
ProgramProgram Define
Interface Insurance with methods: details()(name, types of services), no. of branches(), No. of customers(), annual_income(). Implement these methods in its Implementation class LIC, National, BajajAlliance
Java Virtual Machine Free Download Machine is required to run your java
program in your
computer. The Java Virtual
Machine software is freely downloadable from the sun
website. To run your
program we...
Java Virtual
Machine Free Download
collection interfacecollection interface methods of collection
interface and their description with example
program?
Please visit the following links:
http://www.roseindia.net/java/jdk6/Collection-Interfaces.shtml
http
collection interfacecollection interface methods of collection
interface and their description with example
program?
Please visit the following links:
http://www.roseindia.net/java/jdk6/Collection-Interfaces.shtml
http