I needed some help with this the pseudo code was in python and we need to do it in Java.
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->1
Enter the number of burgers you want 3
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->3
Enter the number of sodas you want 2
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->1
Enter the number of burgers you want 1
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->2
Enter the number of fries you want 2
Do you want to end your order? (Enter yes or no): yes
The total price is $ 8.1832
Do you want to end program? (Enter no to process a new order): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->2
Enter the number of fries you want 2
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->3
Enter the number of sodas you want 2
Do you want to end your order? (Enter yes or no): yes
The total price is $ 3.9856
Do you want to end program? (Enter no to process a new order): yes
Java help
Started by mb52, Jul 01 2010 05:39 AM
3 replies to this topic
#1
Posted 01 July 2010 - 05:39 AM
|
|
|
#2
Posted 01 July 2010 - 12:34 PM
I won't do the code for you, but I can point you in the right direction.
Use a while loop, prompting if users want to continue. The Scanner class with a system.in stream can be used for console input.
Use a while loop, prompting if users want to continue. The Scanner class with a system.in stream can be used for console input.
#3
Posted 05 July 2010 - 08:35 AM
Thank you, would you be able to show me an example of the loop statement?
#4
Posted 05 July 2010 - 10:16 AM
String input;
Boolean again = true;
Scanner scanner = new Scanner(System.in);
while(again){
...
...
...
while( !input.equals("true") || !input.equals("no") ) {
System.out.println("Do you want to go again?");
input= scanner.nextLine();
}
again = input.equals("true");
}


Sign In
Create Account

Back to top









