import java.util.Scanner; public class MP2{ 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!");

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

import java.util.Scanner;
public class MP2{

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!");

}
}

Programming Problem:
Using Loops and Methods that were previously discussed in modules 8&9, modify the
program code you have submitted in MP2 to do the following:
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.
Transcribed Image Text:Programming Problem: Using Loops and Methods that were previously discussed in modules 8&9, modify the program code you have submitted in MP2 to do the following: 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education