java exercise

java exercise

View Answers

November 6, 2008 at 7:17 PM

Hi
Here s ur solution


import java.io.*;

class pizza
{

public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
BufferedReader br2 = new BufferedReader(new InputStreamReader(System.in));
String str;
String str1;
String str2;
String str3;
int choice;
int cost_of_pizza=0;
int cost_of_drinks=0;
int pizza_total=0;
int no_of_pizza=0;
int no_of_drinks=0;
int drinks_total=0;
int grand_total=0;
int discount=0;
int choice1=0;
int choice2=0;
String pizzaa = new String();
String drinks = new String();
System.out.println("");
System.out.println("\t\tPIZZA MENU");
System.out.println("");
System.out.println("S.NO TYPES NORMAL COST SUPER COST");
System.out.println("1 Margaritha 36.00 54.00");
System.out.println("2 Hawaii 40.00 60.00");
System.out.println("3 Special 56.00 84.00");
System.out.println("");
System.out.println("How many pizza's you wanna order ");
str = br.readLine();
no_of_pizza = Integer.parseInt(str);
System.out.println("");
System.out.println("You oredered "+no_of_pizza+" pizza's");
System.out.println("");
System.out.println("Which pizza you need ");
System.out.println("");
str = br.readLine();
choice = Integer.parseInt(str);
if(choice==1)
{
System.out.println("You selected Margaritha");
pizzaa = "Margaritha";
System.out.println("");
System.out.println("Which cost you prefare");
System.out.println("");
System.out.println("press 1 for Normal cost and 2 for Super cost");
str = br.readLine();
choice = Integer.parseInt(str);
if(choice==1){
System.out.println("");
System.out.println("You selected Normal cost");
cost_of_pizza=36;
}
else if(choice==2){
System.out.println("");
System.out.println("You selected Super cost");
cost_of_pizza=54;
}
else
System.out.println("Sorry ur's was wrong selection");
}
else if(choice==2)
{
System.out.println("You selected Hawaii ");
pizzaa = "Hawaii";
System.out.println("");
System.out.println("Which cost you prefare");
System.out.println("");
System.out.println("press 1 for Normal cost and 2 for Super cost");
str = br.readLine();
choice = Integer.parseInt(str);
System.out.println("");
if(choice==1){
System.out.println("You selected Normal cost");
cost_of_pizza=40;
}
else if(choice==2){
System.out.println("You selected Super cost");
cost_of_pizza=60;
}
else
System.out.println("Sorry ur's was wrong selection");
}
else if(choice==3)
{
System.out.println("You selected Special ");
pizzaa = "Special";
System.out.println("");
System.out.println("Which cost you prefare");
System.out.println("");
System.out.println("press 1 for Normal cost and 2 for Super cost");
str = br.readLine();
choice = Integer.parseInt(str);
System.out.println("");
if(choice==1){
System.out.println("You selected Normal cost");
cost_of_pizza=56;
}
else if(choice==2){
System.out.println("You selected Super cost");
cost_of_pizza=84;
}
else
System.out.println("Sorry ur's was wrong selection");
}
else
System.out.println("Sorry your choice is wrong");


System.out.println("");
System.out.println("");


System.out.println("SOFT DRINKS MENU");
System.out.println("");
System.out.println("S.NO NAME NORMAL COST SUPER COST");
System.out.println("1 Coco cola 15.00 25.00");
System.out.println("2 Aqua Mineral 10.00 15.00");
System.out.println("3 Orange Juice 5.00 15.00");

System.out.println("");
System.out.println("how many drinks you wanna order");

str = br.readLine();
no_of_drinks = Integer.parseInt(str);
System.out.println("");
System.out.println("You oredered "+no_of_drinks+" drink");
System.out.println("");
System.out.println("Which drink you need ");
str = br.readLine();
choice = Integer.parseInt(str);
System.out.println("");
if(choice==1){
System.out.println("You selected Coco Cola");
drinks = "Coco Cola";
System.out.println("Which cost you prefare");
System.out.println("");
System.out.println("press 1 for Normal cost and 2 for Super cost");
str = br.readLine();
choice = Integer.parseInt(str);
System.out.println("");
if(choice==1){
System.out.println("You selected Normal cost");
cost_of_drinks=15;
}
else if(choice==2){
System.out.println("You selected Super cost");
cost_of_drinks=25;
}
else
System.out.println("Sorry ur's was wrong selection");
} else if(choice==2)
{ System.out.println("");
System.out.println("You selected Aqua Mineral ");
drinks = "Aqua Mineral";
System.out.println("");
System.out.println("Which cost you prefare");
System.out.println("");
System.out.println("press 1 for Normal cost and 2 for Super cost");
str = br.readLine();
choice = Integer.parseInt(str);
System.out.println("");
if(choice==1){
System.out.println("You selected Normal cost");
cost_of_drinks=10;
}
else if(choice==2){
System.out.println("You selected Super cost");
cost_of_drinks=15;
}
else
System.out.println("Sorry ur's was wrong selection");
}else if(choice==3)
{ System.out.println("");
System.out.println("You selected Orange juice ");
drinks = "Orange juice";
System.out.println("Which cost you prefare");
System.out.println("press 1 for Normal cost and 2 for Super cost");
str = br.readLine();
choice = Integer.parseInt(str);
if(choice==1){
System.out.println("You selected Normal cost");
cost_of_drinks=5;
}
else if(choice==2){
System.out.println("You selected Super cost");
cost_of_drinks=15;
}
else
System.out.println("Sorry ur's was wrong selection");
}else
System.out.println("Sorry your choice is wrong");

System.out.println("You wanna change selection ");
System.out.println("if tes press 1 else 0");
//char ch = (char) System.in.read();
str = br.readLine();
choice = Integer.parseInt(str);
if(choice==1)
{
System.out.println("what u want");
System.out.println("press 1 to add some more pizza's to the orders");
System.out.println("press 2 to ass some more drinks to the order ");


str = br.readLine();
choice1 = Integer.parseInt(str);
if(choice1==1)
{
System.out.println("how many pizza you need");
str2 = br1.readLine();
choice2 = Integer.parseInt(str2);
no_of_pizza += choice2;
System.out.println("So u need "+no_of_pizza+ " " +pizzaa+ "pizzas");

}
else if(choice1==2)
{
System.out.println("how many drinks you need");
str2 = br1.readLine();
choice2 = Integer.parseInt(str2);
no_of_drinks += choice2;
System.out.println("So u need "+no_of_drinks+ " " +drinks+ " " +" drinks");

}
else
System.out.println("Thanks for ur order");

}
else
System.out.println("Thanks for ur order");

pizza_total = cost_of_pizza * no_of_pizza;
//System.out.println(pizza_total);
drinks_total = cost_of_drinks * no_of_drinks;
//System.out.println(drinks_total);
grand_total = pizza_total + drinks_total;
//System.out.println(grand_total);
if(grand_total > 150)
{
discount = grand_total * 5 / 100;
grand_total = grand_total - discount;
}
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("\t\tBILL");
System.out.println("");
System.out.println("Type of pizza : " +pizzaa);
System.out.println("Qty of pizza : " +no_of_pizza);
System.out.println("Type of drinks : " +drinks);
System.out.println("Qty of drinks : " +no_of_drinks);
System.out.println("Grand total : " +grand_total);



}

}


/*do some exception checks*?
/* Thanks...









Related Tutorials/Questions & Answers:
Asking for exercise - Java Beginners
Asking for exercise  Can you send me a small exercise question -a prograsm for collections in java?  Hi Friend, Please visit the following link: http://www.roseindia.net/javacodeexamples/index.shtml Thanks
exercise.
exercise.  write a program that reads 10 numbers fin the largest number and count the occurrence of the largest number from declared array assume you assigned 4,6,3,2,5,6,6,1 and 6
Advertisements
java exercise - Java Beginners
java exercise  Write a java program that calculates the lease rent... the problem. For more information on Java visit to : http://www.roseindia.net/java/ Thanks   Hi friend, Plz give details with source
java exercise - Java Beginners
java exercise  Pizza ordering program on Java! #write a program which prints out a little pizzaria menu card on the screen like: S.N Types of Pizza Normal cost Super cost 1. Margaritha
Exercise 19
Exercise 19  Duplicates 2 Write a Java program that takes as input a string, determines how many characters has duplicates, and prints out each of those values, along with the count for each. Ignore spaces in the counting
Exercise 16
Exercise 16  Number Format Large numbers are typically written... or -32,768). Write a Java program that accepts as input an integer and outputs the comma-enhanced equivalent of the input value. Censored Write a Java program
Exercise 18
Exercise 18  Duplicates1 Write a Java program that determines how many values in a 100-element array has duplicates, and prints out each of those values, along with the count for each. Use the code given below to fill up your
Exercise 17
Exercise 17  Character Counter Write a program which takes an input string and determines the number of vowels, consonants, digits, and special characters (i.e., all other nonalphanumeric characters) in the string
Exercise 20
Exercise 20  Common Letters Write a program that takes two words as input and finds any common letters that they have. For example, the words â??computerâ?? and â??programâ?? have the letters â??oâ??, â??mâ??, â??pâ??, and â??râ
ModuleNotFoundError: No module named 'exercise'
ModuleNotFoundError: No module named 'exercise'  Hi, My Python... 'exercise' How to remove the ModuleNotFoundError: No module named 'exercise... to install padas library. You can install exercise python with following
ModuleNotFoundError: No module named 'SRSnester_exercise'
ModuleNotFoundError: No module named 'SRSnester_exercise'  Hi, My... named 'SRSnester_exercise' How to remove the ModuleNotFoundError: No module named 'SRSnester_exercise' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'kolibri-exercise-perseus-plugin'
ModuleNotFoundError: No module named 'kolibri-exercise-perseus-plugin' ...: ModuleNotFoundError: No module named 'kolibri-exercise-perseus-plugin' How to remove the ModuleNotFoundError: No module named 'kolibri-exercise-perseus-plugin' error
ModuleNotFoundError: No module named 'tensorflow-exercise-hx'
ModuleNotFoundError: No module named 'tensorflow-exercise-hx'  Hi...: No module named 'tensorflow-exercise-hx' How to remove the ModuleNotFoundError: No module named 'tensorflow-exercise-hx' error? Thanks   Hi
ModuleNotFoundError: No module named 'Exercise-publishing-package'
ModuleNotFoundError: No module named 'Exercise-publishing-package'  ...: No module named 'Exercise-publishing-package' How to remove the ModuleNotFoundError: No module named 'Exercise-publishing-package' error? Thanks
ModuleNotFoundError: No module named 'Exercise-upload-distributions'
ModuleNotFoundError: No module named 'Exercise-upload-distributions'  ...: No module named 'Exercise-upload-distributions' How to remove the ModuleNotFoundError: No module named 'Exercise-upload-distributions' error
ModuleNotFoundError: No module named 'games-mlnd-exercise'
ModuleNotFoundError: No module named 'games-mlnd-exercise'  Hi, My... named 'games-mlnd-exercise' How to remove the ModuleNotFoundError: No module named 'games-mlnd-exercise' error? Thanks   Hi
An exercise using (SRS) as a blue print for Abstraction and Modeling in a one page answer. Was this example correct?
An exercise using (SRS) as a blue print for Abstraction and Modeling in a one page answer. Was this example correct?  The software tool to help automate the process of producing a blueprint for problems with a television
Java code for set...!!!
Java code for set...!!!  Create 2 classes in same package Product.java productId, name, price ProductImpl.java create a set in this and try to add objects of product. You should write this exercise such that it should
Which java can i download?
Which java can i download?  Hello, i'm a beginner on java. Which java can i download for to exercise with my codes? Thanks in advance.   nobody.   And i download Eclipse java. But when i want to install
Java Objectives Question
Java Objectives Question  Exercise 1: Create a file by using any word... as FileStatistics.java. Exercise 2: Create a file that contains your favorite movie quote. Use... Exercise 3: Write an application using the FileInputStream that opens a file
Inheretance and polymorphism - Java Beginners
. merry christmas and happy new year to you! Exercise 1.) A point the x-y plane.... ------------------------------------------------------------------------------ Exercise 2.) Every... in Programming Exercise 1, you must derive the class Circle from the class
Java eft transaction
Java eft transaction  4.3 Problem Constraints The following... of this exercise, a customer may have one or more accounts but will only ever have one... number and account type. 5.1 Exercise 1 Implement the findLinkedAccounts
java program - Java Beginners
java program  ( JUnit Tests) 1. JUnit test (CollectionTest.java.... Notice 1: You are not allowed to use any of the classes in the Java Class Library in this exercise. Notice 2 (Only FoST): Feel free to reuse your own
Java Exercises for Beginners
for the beginners of Java tutorials. The tutorial highlights the facts, which will enable you in terms of Java article and exercises. The exercises will provide you the basic opportunity and chance to understand the facts of Java syntax
java
java  1.Design then implement a Java program that defines... a Java program that defines a constant PI = 3.14159 then use that constant to calculate the area of a circle with radius = 3. 3.Design then implement a Java program
Java Training and Placement
Java Training and Placement How to get better guidance for Java Training and Placement? Java is very hot these days because software industry is looking... developed in Java and open source technologies. So, there is a grate demand of trained
java compilation - UML
java compilation  Every circle has a center and a radiuus. Given the radius , we can determine the circles area and circumference. Given the center... designed the class to capture the properties of a point in programming exercise 3
Implementing ArrayList's functionalities into arrays - Java Beginners
Implementing ArrayList's functionalities into arrays  Hi guys, i'm trying to solve an exercise were is asked to write a program that manages the grades of a list of students (given by the exercise) for one single exam; The list
Craps Game Java Programming Help
Craps Game Java Programming Help  Craps is a casino game that involves the throwing of a pair of dice. Based on the throw, the thrower either gets... of this exercise assume that the thrower always replaces a lost bet
Error Handling in Java Script
Error Handling in Java Script  ... will Learn how to handle error in java script. JavaScript is scripting language used...; Example: The coming exercise uses a try...catch statement. The example calls
Oracle invites Community to Weigh-In on Java EE8
Oracle invites Community to Weigh-In on Java EE8 - Take part in survey... again invited the concerned community for its final selection of latest Java Edition, Java EE 8. Oracle has invited the enterprise development community
hi , i cant make this programmer , can any one help me to make it pls - Java Beginners
; In this exercise we would like to build a system in java ( set of classes... java streams (FileReader, FIleWriter,...) and allows creating and opening of new...://www.roseindia.net/java/example/java/io/ Thanks  i want to make the whole
XML in java - XML
argument.Then modify the program resulting from the this exercise so that it will accept
plz help me - Java Interview Questions
plz help me  1)Rewrite the method in exercise 10 such that it use the binary search algorithm instead. the linear search algorithm is suitable... . use linear search for this algorithm .then test your method in java application
Java Training - Corporate Java Training
Java Training - Corporate Java Training     Learn through Java Training: Java is one of the most popular.... Java technologies enables the programmers to develop desktop applications, web
Apache Log4J is the leading logging framework in Java.
development exercise and it is well written logging code, which provides... of logging library for Java, which was developed by the developers of Apache... for its significant features in the leading Java logging framework. If we consider
Create Web Page with jsp
server. JSP simply application that work with Java inside HTML pages. Now we..." instead of "Date.html". This one the simply exercise for your first application JSP. The HTML file we used in the previous exercise. After
java - UML
circle designed in programming exercise 4.some of the operations that can
Writing First Hello World application in JSP
with Java inside HTML pages. Now we can take any existing HTML page and we...;. This one the simply exercise for your first application JSP. Just modify file
Arrays
of all the values as well. Exercise 2: Write a Java application in which you...Arrays   Hi I need help with the following exercises. Exercise 1: Write a Java application in which the user is prompted for the total number
help me in these - Java Interview Questions
with its characters reversed . ( tool to loot) then test your method in java... your method in java application? 7) write a method that takes an integer value... wrote in exercise 5 8)this is a classic comuter science problem called "towers
What is the best online course to learn R?
\wrapper
\wrapper  Hands on Exercise on Wrapper Class: Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer
\wrapper
\wrapper  Hands on Exercise on Wrapper Class: Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer
\wrapper
\wrapper  Hands on Exercise on Wrapper Class: Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer
wrapper class concept
wrapper class concept  Write a Java class that stores an integer item id, a string item name and a float price. Store all these in a String member... of this exercise, initialize a couple of String objects that contain an integer
JBoss - error during deploy - Java Beginners
JBoss - error during deploy  Hello! I've followed your fantastic tutorial about JBoss but I got stucked in exercise 2. I use JBoss AS 5 (don't really know what AS means but I hope I downloaded the right thing). I try to deploy
Open Source Java Database
Open Source Java Database An Open Source Java Database One$DB is an Open Source version of Daffodil DB, our commercial Java Database. One$DB... or minimal administration. Daffodil DB is the first Java database that has shown
Free Java Books
Free Java Books         Sams Teach Yourself Java 2 in 24 Hours As the author of computer books, I spend a lot... the whip. So I'll keep this brief: This Java programming stuff is a lot easier than
java
java  diff bt core java and java

Ads