Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners program an interface for a futuristic vending machine

Have Programming Question? Ask it here!
 
 
 


soomei
program an interface for a futuristic vending machine
0 Answer(s)      a year and 7 months ago
Posted in : Java Beginners


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.


Advertisement
View Answers

Related Tutorials/Questions & Answers:
program to demonstrate java is machine nutral
program to demonstrate java is machine nutral   can any one give program to demonstrate java is machine nutral
Connect a linux machine from linux using java program without password
Connect a linux machine from linux using java program without password  Connect a linux machine from linux using java program without password. Can anyone help me
Advertisements
program and Interface builder
program 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
producer and concumer Interface program
producer and concumer Interface program  I need producer and concumer Interface program   Hi Friend, Try the following code: import java.util.*; class Multithreading { int val; boolean value = false; synchronized int
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 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   
washing machine
washing machine   Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes   public class
interface
interface   what is the use of marking interface
Interface
Interface  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
interface
interface  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
INTERFACE
INTERFACE  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
interface
interface  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
interface
interface  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
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  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
Interface
Interface  I need to implement the interface without overriding its method and also don't use abstract class for this. How to do
interface
interface  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
Java Virtual Machine
Java: Java Virtual Machine After you read this section, you should be able... Machine. The Java Virtual Machine Most compilers translate from the source language (eg, C or Pascal) into machine language for one specific type
Write an event driven program to perform the arithmetic operations as shown in the interface
Write an event driven program to perform the arithmetic operations as shown... the java programming code for that question. my question is here: Q. Write an event driven program to perform the arithmetic operations as shown
Interface
Interface  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
Interface
Interface  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
Interface
Interface  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
Java Virtual Machine Technology
Java Virtual Machine Technology Java development kit termed as  JDK have.... This is the Virtual machine implementation comes with JDK.It is basically designed to cut... as server VM is specifically developed to enhancing program execution speed
atm machine code - Framework
atm machine code  plz send me the code of atm machine in c#.reply
ATM machine in c#
ATM machine in c#  i am looking for a code that will be able to create an account and be able to log-in to the atm machine
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
Java Virtual Machine
Java Virtual Machine  What is Java Virtual Machine? Are JVM different for each OS? Thanks   Hello, JVM or Java Virtual Machine is run... more at Java Virtual Machine Technology. Thanks
Tattoo Machine
Tattoo Machine: Power to Design on Human Body Before a tattoo machine... to the skin of human body. Reilly's machine was based on the technology of Thomas... use electromagnets in a tattoo machine. Tattoo machines are basically classified
Java Virtual Machine
Java Virtual Machine The Java Virtual Machine is a software package that comes with the JRE or JDK. It is a virtual machine which is responsible for running.... The JVM is responsible for compiling the the byte code for the machine on which
Java Virtual Machine
Java Virtual Machine       In this section, you will learn about the java virtual machine (JVM) and how to work? Java Virtual Machine (JVM) Java Virtual Machine is a set of computer
detection of the operating system on the client machine
detection of the operating system on the client machine  How to detect the operating system on the client machine
First Java Program
and then compile and test the same on your development machine. Write first Program... Machine.  You can write a Hello World program as your first Java... First Java Program      
Discovery Machine Gear
Discovery Machine Gear       The Discovery Machine Modeler allows experts..., and leveraged. Discovery Machine Modeler our core knowledge acquisition
i want to copy files from one machine to other using java and the code will be running on third machine
i want to copy files from one machine to other using java and the code will be running on third machine  i want to copy some files from one machine say 'A' to some other machine say 'B' by using the java program running on third
EJB remote interface
EJB remote interface       The program given below describes  the way of creating a remote interface...;} } Output of the Program Accessing Remote Interface using
Getting list of Local Interfaces on a machine
Getting list of Local Interfaces on a machine... to find out the total no of list of local interfaces available on a machine. Here... a NetworkInterface class of java.net package which represented the local interface. After
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface... is your code, we have modified it. import java.io.*; interface arith { int a=5
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface... is your code, we have modified it. import java.io.*; interface arith { int a=5
collection interface
collection 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 interface
collection 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
What is an interface?
What is an interface?  What is an interface
Save file on Client Machine - Development process
server machine and all the users of the application are accessing them as http://boserver:9090/AI where boserver is the name of server machine, now when a client from his machine try to save the file it gets saved in the serve machine i want
Can an Interface implement another Interface?
Can an Interface implement another Interface?   Hi, Can an Interface implement another Interface? Thanks
Can an Interface extend another Interface?
Can an Interface extend another Interface?   Hi, Can an Interface extend another Interface? thanks
ServletRequest interface
ServletRequest interface   What is new in ServletRequest interface
Set Interface
Set Interface       The Set interface extends the Collection interface.... It permits a single element to be null. The Set interface contains only methods
Advertisements
 

 

 

DMCA.com