Write a Menu-driven Program which provides the options to choose from
Breakfast/Main Course/Beverages and then as per the user's selection provide
different options available in that category along with price.
Allow the user to select the items and enter their quantity.
Generate the Bill at the End when User choose to EXIT.
import java.util.*;
class MyRestaurant
{
private static String [][] breakfast ={
{"Chhole Bhature", "60"},
{"Veg Sandvich", "50"},
{"Noodles " , "80"},
{"Chana Samosa", "45"}
};
private static String [][] beverages ={
{"Tea", "15"},
{"Coffee", "50"},
{"Cold Drink" , "30"},
{"Lassi", "45"}
};
private static String [][] main_course ={
{"Butter Naan", "35"},
{"Shahi Paneer", "160"},
{"Mix Veg" , "110"},
{"Malai Kofta", "145"},
{"Daal Makhani", "95"},
{"Veg Biryani", "70"},
{"Manchurian" , "120"},
{"Malai Methi", "130"}
};
private static void printMenu(String [][] category)
{
System.out.println("n----------------------------------------n");
for(int i=0; i<category.length; i++)
System.out.println(category[i][0] + "tt" + category[i][1]);
System.out.println("n---------------------------------------------");
System.out.print("nntEnter Your Choice:t");
}
private static void mainMenu()
{
System.out.println("nt * * * * * Chaupal * * * * *");
System.out.println("--------------------------------------------");
System.out.println("1. Breakfast");
System.out.println("2. Main Course");
System.out.println("3. Beverages");
System.out.println("0. Exit");
System.out.print("ntEnter Your Choice:t");
}
public static void main(String [] rk)
{
Scanner sc = new Scanner(System.in);
mainMenu(); //User is supposed to enter 0/1/2/3
int c = sc.nextInt();
switch(c)
{
case 0: System.exit(0);
case 1: System.out.println("nnYou Have Selected BREAKFASTn");
printMenu(breakfast);
break;
default: System.out.println("nnYou Given INCORRECT Input: "+c);
mainMenu(); break;
case 2: System.out.println("nnYou Have Selected MAIN COURSEn");
printMenu(main_course);
break;
case 3: System.out.println("nnYou Have Selected BEVERAGESn");
printMenu(beverages);
}
}
}
