1. Place all the Menus in separate Methods. 2. Place computations in separate Methods and call the methods once needed.
import java.util.Scanner;
public class Resto{
public static void main (String[] args){
//initialization and declaration
Scanner input = new Scanner (System.in);
String message;
int Option1;
int Option2;
int Quantity;
int TotalBill;
int Cash;
int Change;
final int SPECIALS = 1;
final int BREAKFAST = 2;
final int LUNCH = 3;
final int SANDWICHES = 4;
final int DRINKS = 5;
final int DESSERTS = 6;
//For the Special, Breakfast, Lunch Options
final int Meals1 = 11;
final int Meals2 = 12;
final int Meals3 = 13;
final int Meals4 = 14;
//First menu and First Option
System.out.println("\t Welcome to My Kitchen ");
System.out.println("\t\t SPECIALS");
System.out.println("\t\t [2] BREAKFAST MEALS");
System.out.println("\t\t [3] LUNCH MEALS");
System.out.println("\t\t [4] SANDWICHES");
System.out.println("\t\t [5] DRINKS");
System.out.println("\t\t [6] DESSERTS");
System.out.println("\t\t [0] EXIT");
System.out.print("Choose an option ");
Option1 = input.nextInt();
//first switch case statements
switch(Option1){
case (SPECIALS):
message = "**********[SPECIALS]**********\n\t [11] Baked Macaroni \n\t [12] Baked Spaghetti \n\t [13] Beef with Vegetables \n\t [14] Mongolian BBQ \n\n\t [0] Exit";
break;
case (BREAKFAST):
message = "**********[BREAKFAST MEALS]**********\n\t [11] Egg & Bacon with Rice \n\t [12] Egg & Longganisa with Rice \n\t [13] Omelette \n\t [14] Pancake BBQ \n\n\t [0] Exit";
break;
case (LUNCH):
message = "**********[LUNCH MEALS]**********\n\t [11] Beef Ribs \n\t [12] Burger Steak \n\t [13] Fried Chicken Fillet \n\t [14] Pork BBQ \n\n\t [0] Exit";
break;
case (SANDWICHES):
message = "**********[SANDWICHES]**********\n\t [1] Clubhouse Sandwich \n\t [2] Cheeseburger \n\t [3] Grilled Cheese Sandwich \n\t [4] Ham & Cheese Sandwich \n\n\t [0] Exit";
break;
case (DRINKS):
message = "**********[DRINKS]**********\n\t [1] Coke \n\t [2] Sprite \n\t [3] RootBeer \n\n\t [0] Exit";
break;
case (DESSERTS):
message = "**********[DESSERTS]**********\n\t [1] Fruit Salad \n\t [2] IceCream \n\t [3] Cheesecake \n\n\t [0] Exit";
break;
default:
message = "Thank You and come again";
break;
}
System.out.println(message);
//2nd Options and 2nd switch case statements
System.out.print("Choose an option: ");
Option2 = input.nextInt();
switch (Option2){
case (SPECIALS):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (BREAKFAST):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (LUNCH):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (SANDWICHES):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (DRINKS):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (DESSERTS):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (Meals1):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (Meals2):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (Meals3):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
case (Meals4):
message = "**********[Choices]**********\n\t [11] Small \n\t [12] Medium \n\t [13] Large \n\t [14] Extra Large \n\n\t [0] Exit";
break;
default:
message = "Thank you and come again";
break;
}
System.out.print(message);
System.out.print("Choose an option: ");
Option1= input.nextInt();
//Computing for the prices and giving change
System.out.print("Quantity: ");
Quantity = input.nextInt();
TotalBill = Quantity * 50;
System.out.println("Total Bill is "+TotalBill);
System.out.print("Cash: ");
Cash = input.nextInt();
Change = Cash - TotalBill;
//if statement
if (Cash < TotalBill)
System.out.print ("Not enough payment");
else
System.out.println ("Change is: "+Change);
//Outro
System.out.println("Thank You and come again at My Kitchen!");
}
}
![1. Place all the Menus in separate Methods.
2. Place computations in separate Methods and call the methods once needed.
3. Enable looping of the program to:
a. Return to specific Menu (e.g. Meal Menu, Drinks Menu, Pasta Menu, etc.)
b. Return to the Main Menu from any point within the program
c. Let the program repeat until the customer doesn't want to order anymore.
Please note: Menu structures and variables need to be labeled with intuitive identifier
names intended for their purpose.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F32509d8f-3eb8-412a-b22b-8919afa8e523%2F06b78f22-a49e-43a8-84e7-4d03ae67ccc8%2Fnbajev8_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)