Question

Level 3 - Create a menu with toppings and able to order multiple items with the choice of 1 topping (max grade 95/100): a) Usmenu items array of String numMenuItems int startover - char input - Scanner Main method: 1. Greet the customer 2. Get number

Sample Execution – Level 3
Welcome to your Menu Creation system.
How many items would you like to have on your menu? 2
Create your menu!
Enter item #1: Coffee
Enter the number of toppings: 2
Enter topping #1: Whipped Cream
Enter topping #2: Cinnamon
Enter item #2: Tea
Enter the number of toppings: 2
Enter topping #1: Milk
Enter topping #2: Sugar
May I take your order?
This is the menu:
Coffee
Tea
Pop
How many items would you like to order? 2
What is choice #1: Cake
That isn’t on our menu.
What is choice #1: Tea
Topping Choice #1 Milk
Topping Choice #2 Sugar
What topping would you like? 1
What is choice #2: Cake
That isn’t on our menu.
What is choice #2: Coffee
Topping Choice #1 Whipped Cream
Topping Choice #2 Cinnamon
What topping would you like? 1
This is your order:
Tea with Milk
Coffee with Whipped Cream
Thank you for your order. Would you like to start over? n
Goodbye!

Sample Run - Level 2 with Bonus
Menu can be added to any of the levels to earn the possible 10% extra

Welcome to your Menu Creation system.
Please make a selection (1-3):
1. Create a new menu 2. Take an order 3. Quit
2
You need to create a menu first
Please make a selection (1-3):
1. Create a new menu
2. Take an order 3. Quit
1
How many items would you like to have on your menu? 3
Create your menu!
Enter item #1: Coffee
Enter item #2: Tea
Enter item #3: Pop
May I take your order?
This is the menu:
Coffee
Tea
Pop
How many items would you like to order? 2
What is choice #1: Cake
That isn’t on our menu.
What is choice #1: Tea
What is choice #2: Cake
That isn’t on our menu.
What is choice #2: Coffee
This is your order:
Tea
Coffee
Please make a selection (1-3):
1. Create a new menu 2. Take an order 3. Quit
2
May I take your order?
This is the menu:
Coffee
Tea
Pop
How many items would you like to order? 1
What is choice #1: Cake
That isn’t on our menu.
What is choice #1: Tea
This is your order:
Tea
Please make a selection (1-3):
1. Create a new menu 2. Take an order 3. Quit
3
Thank you for using this Menu Creation system.

Please use simple java code. Use methods that I post in screenshot.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


/*java program that demonstrates the menu to create menu items
* and the taking order in the below java program. The output
* is displayed at the end of the source code.*/
//MenuOrder.java
import java.util.Scanner;
public class MenuOrder
{
   public static void main(String[] args)
   {
       int numMenuItems;
       boolean menuCreated=false;
       char startOver='y';
       int choice;
       Scanner input=new Scanner(System.in);
       //Create an array of string of size ,numMenuItems
       String menuItems[] = null;
              
       System.out.println("Welcome to your Menu Creation system.");
       /*Repeat until startOver is y */
       while(startOver=='y')
       {
           System.out.println("Please make a selection (1-3):");
           System.out.println("1. Create a new menu 2. Take an order 3. Quit");
           //read choice from keyboard
           choice=Integer.parseInt(input.nextLine());      
          
           //if else statements
           if(choice==1)
           {
               menuCreated=true;
               System.out.print("How many items would you like to have on your menu?");
               numMenuItems=Integer.parseInt(input.nextLine());
               //Create an array of string of size ,numMenuItems
               menuItems=new String[numMenuItems];
               //calling methods
               createMenu(menuItems, input);
               takeOrder(menuItems, input);
           }
           else if(choice==2 && !menuCreated)
           {
               System.out.println("You need to create a menu first");
           }      
           else if(choice==2 && menuCreated)
           {
               takeOrder(menuItems, input);
           }
           else if(choice==3)
           {
               System.out.println("Thank you for using this Menu Creation system.");
               startOver='n';
           }
       }   //end of while loop
      
   }
   /*Method, createMenu that takes menuItems array and input scanner
   * and then read the item names from the keyboard */
   public static void createMenu(String[] menuItems, Scanner input)
   {
       System.out.println("Create your menu!");
       for (int index = 0; index < menuItems.length; index++)
       {
           System.out.print("Enter item #"+(index+1)+":");
           menuItems[index]=input.nextLine();
       }
   }
  
   /*Method takeOrder that takes string menu items and input scanner
   * and then take orders from the keyboard */
   public static void takeOrder(String[] menuItems, Scanner input)
   {
       String orderedItem="";
       String itemName;
       int numItems=0;
       boolean found=false;
      
       System.out.println("May I take your order?");
       System.out.println("This is the menu:");
       //print the menu items
       for (int i = 0; i < menuItems.length; i++)
           System.out.println(menuItems[i]);  
       System.out.print("How many items would you like to order?");
       //read number of items to get order
       numItems=Integer.parseInt(input.nextLine());
       for (int i = 0; i < numItems; i++)
       {          
           do
           {
               System.out.print("What is choice # "+(i+1)+":");
               itemName=input.nextLine();      
               for (int itmIndex = 0; itmIndex < menuItems.length; itmIndex++)
               {
                   if(itemName.equals(menuItems[itmIndex]))
                       found=true;
               }  
               //print message if found is false
               if(!found)
                   System.out.println("That isn’t on our menu.");
           }while(!found);
           //add itemName to the orderedItem string
           orderedItem+=itemName+"\n";
           found=false;
       }  
       System.out.println("This is your order:");
       System.out.println(orderedItem);
   } //end of the method
}
-----------------------------------------------------------------------------------------------------------------

Sample Output:(Sample Run - Level 2)

Welcome to your Menu Creation system. Please make a selection (1-3): 1. Create a new menu 2. Take an order 3. Quit 2 You need

What is choice # 2:Cake That isnt on our menu. What is choice # 2:Coffee This is your order: Tea Coffee Please make a select

Please make a selection (1-3): 1. Create a new menu 2. Take an order 3. Quit 3 Thank you for using this Menu Creation system.

Welcome to your Menu Creation system.
Please make a selection (1-3):
1. Create a new menu 2. Take an order 3. Quit
2
You need to create a menu first
Please make a selection (1-3):
1. Create a new menu 2. Take an order 3. Quit
1
How many items would you like to have on your menu?3
Create your menu!
Enter item #1:Coffee
Enter item #2:Tea
Enter item #3:Pop
May I take your order?
This is the menu:
Coffee
Tea
Pop
How many items would you like to order?2
What is choice # 1:Cake
That isn’t on our menu.
What is choice # 1:Tea
What is choice # 2:Cake
That isn’t on our menu.
What is choice # 2:Coffee
This is your order:
Tea
Coffee

Please make a selection (1-3):
1. Create a new menu 2. Take an order 3. Quit
2
May I take your order?
This is the menu:
Coffee
Tea
Pop
How many items would you like to order?1
What is choice # 1:Cake
That isn’t on our menu.
What is choice # 1:Tea
This is your order:
Tea

Please make a selection (1-3):
1. Create a new menu 2. Take an order 3. Quit
3
Thank you for using this Menu Creation system.

Note: The given program specifications are matched with Level 2 output. The above program is

designed for Level2 output since it is matched with the given question specifications.

Add a comment
Know the answer?
Add Answer to:
Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Your assignment is to create a restaurant ordering system where the cashier can create the menu...

    Your assignment is to create a restaurant ordering system where the cashier can create the menu and then take in the order and display the order back to the customer Sample Execution – Level 1 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter item #2: Tea This is the menu: Coffee Tea What would you like to order? Cake That isn’t on...

  • Krunchy Krabcakes is a seafood restaurant which serves a very limited menu of sea-based delicacies. The...

    Krunchy Krabcakes is a seafood restaurant which serves a very limited menu of sea-based delicacies. The menu consists of the following items with associated prices: Crabcake $4.59 Shrimp Wrap $7.79 Lobster Soup $9.39 Write a Java program which displays a menu to the customer which allows them to place an order consisting of one or more of these menu items. The menu should use a simple numeric selection method to order an item. For example, '1' orders a crabcake, '2'...

  • Assume that a restaurant offers the following breakfast items: Plain Egg $1.45 Bacon and Egg $2.45...

    Assume that a restaurant offers the following breakfast items: Plain Egg $1.45 Bacon and Egg $2.45 Muffin $0.99 French Toast $1.99 Fruit Basket $2.49 Cereal $0.69 Coffee $0.50 Tea $0.75 Write a program that stores the following data about each menu item in a structure called MenuItem: • A description of the menu item • The price of the menu item • A count of the number of times the item has been ordered
 The program should keep an array...

  • In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast...

    In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...

  • Class, As a chef, what would you do with the following menu items on your menu:...

    Class, As a chef, what would you do with the following menu items on your menu: 1. A dog item 2. A plowhorse Think of at least 2 different effective solutions and share them in detail in your initial post.

  • Write a C++ program to tally up the total cost of a customer order for Roasterie...

    Write a C++ program to tally up the total cost of a customer order for Roasterie coffee shop. The coffee shop offers the following items on its menu: • Coffee($2.5) • Tea($2.25) • Soda($1.85) • Juice($2) • Special Item(self defined price) The program takes input from the user about all the items and amounts. Below is an example: - Please input item number: 1. Tea 2. Soda 3. Juice 4. Special Item - 1 - How many: - 3 -...

  • The Jumpin Jive coffee shop charges $2 for a cup of coffee and offers add ins...

    The Jumpin Jive coffee shop charges $2 for a cup of coffee and offers add ins shown in the pseudocode. Using the following Pseudocode, Design the logic for an application that allows a user to enter ordered add ins continuously until a sentinel value is entered. After each item, display its price or the message "Sorry, we do not carry that" as an output. After all items have been entered, display the total price for the order. Please write it...

  • #include <iostream> #include <iomanip> #include <vector> #include <string> using namespace std; struct menuItemType { string menuItem;...

    #include <iostream> #include <iomanip> #include <vector> #include <string> using namespace std; struct menuItemType { string menuItem; double menuPrice; }; void getData(menuItemType menuList[]); void showMenu(menuItemType menuList[], int x); void printCheck(menuItemType menuList[], int menuOrder[], int x); int main() { const int menuItems = 8; menuItemType menuList[menuItems]; int menuOrder[menuItems] = {0}; int orderChoice = 0; bool ordering = true; int count = 0; getData(menuList); showMenu(menuList, menuItems); while(ordering) { cout << "Enter the number for the item you would\n" << "like to order, or...

  • How do I record every user Input and then display all of it in the scream....

    How do I record every user Input and then display all of it in the scream. In my code i ask the user for a series of food item, then i ask for the toppings. I need to display every input of food and toppings the user enters. The output must look like this Here is your order <name> Appetizer: [ Wings, Blue cheese, Ranch ] Main Course: [ Hamburger: mushrooms , Advocado ] Dessert: [ Pie: Powder Sugar, Scoop...

  • Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's ...

    Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant. That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals. You have been approached to create a computer program that will accurately calculate bills for each customer. Kids, under 5, eat free. Teens and seniors get a 25% discount. Also, Food and beverage is taxed at 5%. No tax for anything...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT