dont know how to solve this java..........
807605Aug 27 2007 — edited Aug 27 2007i wanna make 'burger calculation system'...in this problem i dont know how to jump to next question when u disagree to order...i dont know how to do when press 'b' to disagree.......plzz help..
import java.io.*;
public class kraby{
public static void main(String[]args)throws IOException{
DataInputStream io = new DataInputStream (System.in);
String [] ing;
ing = new String[12];
String[]price;
price = new String [12];
ing [0] = "Salad RM0.20";
ing [1] = "Red onion RM0.20 ";
ing [2] = "Green onion RM0.20";
ing [3] = "Cheese RM1.00";
ing [4] = "A spoon of coleslaw RM0.40";
ing [5] = "Egg RM0.70";
ing [6] = "Chili sauce RM0.20";
ing [7] = "Tomato sauce RM0.20";
ing [8] = "Mayonis RM0.20";
ing [9] = "Beef RM0.90";
ing [10] = "Chicken RM1.00";
ing [11] = "Pork RM2.00";
price [0] = "0.20";
price [1] = "0.20";
price [2] = "0.20";
price [3] = "1.00";
price [4] = "0.40";
price [5] = "0.70";
price [6] = "0.20";
price [7] = "0.20";
price [8] = "0.20";
price [9] = "0.90";
price [10] = "1.00";
price [11] = "2.00";
String var;
int TotalPrice;
int order;
int quantity;
double calc;
System.out.println (ing[0]);
System.out.println("\t\t\t_______________________");
System.out.println("\t\t\tWelcome to Krusty Krab");
System.out.println("\t\t\t_______________________");
System.out.println();
System.out.println();
System.out.println("Please choose the ingredients of ur burger");
System.out.println();
System.out.println();
System.out.println("\t\t\t#######MENU#######");
System.out.println();
System.out.println("\t_____________________________________________________");
System.out.println("\tIngredients Price");
System.out.println("\t_____________________________________________________");
System.out.println();
System.out.println("\t 1.Salad RM0.20 ");
System.out.println("\t 2.Red onion \tRM0.20");
System.out.println("\t 3.Green onion \t\tRM0.20");
System.out.println("\t 4.Cheese(per slice) \t\tRM1.00");
System.out.println("\t 5.A spoon of coleslaw \t\tRM0.40");
System.out.println("\t 6.Egg \t\t\tRM0.70");
System.out.println("\t 7.Chili sauce \t\tRM0.20");
System.out.println("\t 8.Tomato sauce \t\t\tRM0.20");
System.out.println("\t 9.Mayonis \t\t\tRM0.20");
System.out.println("\t 10.Beef(per piece) \t\tRM0.90");
System.out.println("\t 11.Chicken(per piece) \t\tRM1.00");
System.out.println("\t 12.Pork(per piece) \t\tRM2.00");
System.out.println();
System.out.println("do you want put salad on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of each salad");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.20;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
System.out.println("do you want put red onion on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of each red onion");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.20;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put green onion on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of each green onion");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.20;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put cheese on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur slice of each cheese");
quantity = Integer.parseInt(io.readLine());
calc = quantity*1.00;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put a spoon of coleslaw on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of spoon of coleslaw");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.40;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put egg on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of each egg");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.70;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put chili sauce on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of each chili sauce");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.20;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put tomato sauce on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of each tomato sauce");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.20;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put mayonis on your burger?");
System.out.println("press 'a' to agree and press 'b' to disagree");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur quantity of each mayonis");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.20;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
return
System.out.println("do you want put beef,chicken or pork on your burger?");
System.out.println("press 'a' for beef,press 'b' for chicken and press 'c' for pork");
var = io.readLine();
if(var.equals("a")){
System.out.println("Please insert ur piece of beef");
quantity = Integer.parseInt(io.readLine());
calc = quantity*0.90;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("b")){
System.out.println("Please insert ur piece of chicken");
quantity = Integer.parseInt(io.readLine());
calc = quantity*1.00;
System.out.println();
System.out.println("the price now\tRM"+calc);
else if(var.equals("c")){
System.out.println("Please insert ur piece of pork");
quantity = Integer.parseInt(io.readLine());
calc = quantity*2.00;
System.out.println();
System.out.println("the price now\tRM"+calc);