# LOOPing for Biggner

• 10-08-2011, 05:16 PM
LogicBrix
LOOPing for Biggner
can you help me with this problem ...

example:

Quote:

====WELCOME to our REStaurant====
CODE=== Name=== PRICE
...1.===.Chicken ====\$5
...2.===.burger=== ==\$2
...3.===.Hotdog==== \$3

What is your order sir ?[Enter the Code]: 1
//if i enter a code that dont have in the menu .. it will ask again for the code

Enter Quantity: 1

Do you want to enter again? (y/n) :

//if i enter Y it will loop again ...
//if i enter N it will show the receipt

===RECEIPT===
customer 1: \$5
customer 2: \$6
...............------
...............\$11 // all his order will be add ...
its just an example .... im stuck with that .. that how i can make that if i enter Y , 5 times it will show Customer 5 and then add the price ...
• 10-08-2011, 05:20 PM
Fubarable
Re: LOOPing for Biggner
First please show us your attempt, any attempt, to solve it. Let us know if your code shows any errors or any misbehaviors.
• 10-08-2011, 06:09 PM
LogicBrix
Re: LOOPing for Biggner
Here it is ..

Code:

```import java.io.*; public class Ticket {         public static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));         public static void main(String args [])throws Exception { // First declare your constants double BURGER = 1; double FRIES = 2; double COKE = 3; // Display the list of shows and prices to the user System.out.println("Menu:"); System.out.println("1. Burger \$1.99"); System.out.println("2. Fries \$1.69"); System.out.println("3. Coke \$1.49"); // Prompt for and read in the number of the show int orderNumber = 0; int orderAmount = 0; double price = 0; String YN = ""; String error = ""; do { System.out.print("Enter desired item: "); orderNumber = Integer.parseInt(input.readLine()); // Prompt for and read in the number of the item if(orderNumber != 99) {     System.out.print("How many would you like?: ");     orderAmount =Integer.parseInt(input.readLine()); } // Use a switch statement to determine what price to use switch (orderNumber) { case 1: price += BURGER * orderAmount; break; case 2: price += FRIES * orderAmount; break; case 3: price += COKE * orderAmount; default: System.out.print("Sorry Wrong Code"); break; } System.out.print("do you want To order again ? (y/n)"); YN = input.readLine();         if(YN.equalsIgnoreCase("n"))         {                                 double total = price;         System.out.println("Total: "+ total);         }                 else if(YN.equalsIgnoreCase("y"))         {                                }         else         {                 System.out.println("Invalid entry has occured, would you like to try again? Enter Y or N");                 YN = input.readLine();                                 if(YN.equalsIgnoreCase("N"))                         {                                 double subtotal = price;                 System.out.println("Subtotal:"+ subtotal);                         }                 if(YN.equalsIgnoreCase("Y"))                         {                                 }         }                        } while(YN.equalsIgnoreCase("y")); } }```
i want to loop that if the user enter Y , then it will loop for another customer , but im stuck ... i cant do it ..:@::@::@::@::=(: