Professional Documents
Culture Documents
system;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
int orderAgain = 0;
do{
separator();
System.out.println("Menu:\n"
+ "[1]Burger = 45\n"
+ "[2]Fries = 30\n"
+ "[3]Milktea = 60\n");
Choice();
switch(choice){
case 1:
currentPrice = burgerPrice;
orderlist.add("Burger = p45");
break;
case 2:
currentPrice = friesPrice;
orderlist.add("Fries = P30");
break;
case 3:
currentPrice = milkteaPrice;
orderlist.add("Milktea = P60");
break;
default:
System.out.println("Invalid Input");
}
separator();
multiplyTo();
orderlist.set(orderlist.size()-1, orderlist.get(orderlist.size()-1) + " -
x" + quantity);
separator();
System.out.println(" Do you want to order again? [1]Yes | [2] No:");
separator();
Choice();
}while(choice == 1);
separator();
int count = 1;
for (String display : orderlist){
System.out.println(count+ "." + display);
count++;
}
separator();
System.out.println("The total price is: "+totalPrice);
separator();
}
static void multiplyTo(){
while(true){
try{
System.out.println("mutiply To: ");
String multiplyTo = scan.next();
quantity = Integer.parseInt(multiplyTo);
if (quantity <= 0){
System.out.println(" Must be positive number.");
separator();
}else{
totalPrice += currentPrice * quantity;
break;
}
}catch(NumberFormatException nfe){
}
}
}