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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Raju Basnet
java exercise
1 Answer(s)      6 years and 2 months ago
Posted in : Java Beginners



Advertisement
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
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
Advertisements
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.
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
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‚
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
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
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 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
java  diff bt core java and java
java
java  what is java
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
Java
Java   Whether Java is pure object oriented Language
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
Advertisements
 

 

 

DMCA.com