In: Computer Science
write a java program for a restaurant menu. including price , add taxes and include tip
// PLEASE LIKE THE SOUTION
// FEEL FREE TO DISCUSS IN COMMENT SECTION
// JAVA PROGRAM
import java.util.*;
class Restaurant{
// main method
public static void main(String arg[]){
// now printing the menu and ask
for selection
Scanner scan = new
Scanner(System.in);
// menu
String item[] =
{"Pizza","Berger","Sandwitch","Tea","Coffee"};
// price
double price[] =
{300.0,200.0,150.0,50.0,120};
// loop till exit is not
pressed
double sum = 0;
while(true){
// print
menu
for(int
i=0;i<item.length;i++){
System.out.println((i+1)+".
"+item[i]+"\t"+price[i]);
}
System.out.println("0. Exit");
// now
input
int in =
scan.nextInt();
if(in !=
0){
// add to total
sum += price[in-1];
}
else{
// print all sum
System.out.println("ItemTotal = "+sum);
System.out.println("Tax = "+(0.05*sum));
System.out.println("Tip = "+10.0);
System.out.println("Total =
"+(sum+(0.05*sum)+10));
break;
}
}
}
}
// SAMPLE OUTPUT