2. In your main class: a. Define the method addElement which takes an array of integers and an integer, and returns a new array that is formed by adding the integer to the end of the passed array. b. Define the void method makeAnOrder which takes an object of type Menu and performs the following: - Print the passed menu by invoking the printMenu method for the passed object. - Ask the user to enter the index of the meal he wants to order, and then create an array of integers that consists initially of the index he entered. This array will include the indices of the meals the user will order. - The method must then ask the user if he wants to add more meals. If he wants to add more meals, it must ask him to enter the index of the meal and add the index to the array of orders by invoking the addElement method. The method should keep on asking the user if he wants more meals and reading the indices of the meal until he enters that he does not want to add more meals. - The method must compute the total payment of the order by summing the prices of the ordered meal. - The method must invoke the incrementNumOrdered method for each ordered meal using its index. - At the end of the method, the order should be displayed by printing the ordered meals name-price cach on a line, and print the total payment amount on the last line. d. Define the method isMealOrdered which takes an array of integers (that represents an order of meal indices) and an integer (that represents a meal index). The method should return true if the integer (meal) is found in the order and false otherwise. e. In your main method, perform the following in order: - Print the number of menus created. - Create an object of type Menu named menul using the no-arg constructor. - Create an object of type Menu named menu2 using the second constructor and pass menul as an argument. - Invoke the method makeAnOrder twice by passing menul in the first time and menu2 in the second.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a Java program that implements the following cause
2. In your main class:
a. Define the method addElement which takes an array of integers and an integer, and returns a
new array that is formed by adding the integer to the end of the passed array.
b. Define the void method makeAnOrder which takes an object of type Menu and performs the
following:
- Print the passed menu by invoking the printMenu method for the passed object.
- Ask the user to enter the index of the meal he wants to order, and then create an array of integers that
consists initially of the index he entered. This array will include the indices of the meals the user will
order.
- The method must then ask the user if he wants to add more meals. If he wants to add more meals, it must
ask him to enter the index of the meal and add the index to the array of orders by invoking the addElement
method. The method should keep on asking the user if he wants more meals and reading the indices of the
meal until he enters that he does not want to add more meals.
- The method must compute the total payment of the order by summing the prices of the ordered meal.
- The method must invoke the incrementNumOrdered method for each ordered meal using its index.
- At the end of the method, the order should be displayed by printing the ordered meals name-price each
on a line, and print the total payment amount on the last line.
d. Define the method isMealOrdered which takes an array of integers (that represents an order of
meal indices) and an integer (that represents a meal index). The method should return true if
the integer (meal) is found in the order and false otherwise.
e. In your main method, perform the following in order:
- Print the number of menus created.
- Create an object of type Menu named menul using the no-arg constructor.
- Create an object of type Menu named menu2 using the second constructor and pass menul as an
argument.
- Invoke the method makeAnOrder twice by passing menul in the first time and menu2 in the second.
Transcribed Image Text:2. In your main class: a. Define the method addElement which takes an array of integers and an integer, and returns a new array that is formed by adding the integer to the end of the passed array. b. Define the void method makeAnOrder which takes an object of type Menu and performs the following: - Print the passed menu by invoking the printMenu method for the passed object. - Ask the user to enter the index of the meal he wants to order, and then create an array of integers that consists initially of the index he entered. This array will include the indices of the meals the user will order. - The method must then ask the user if he wants to add more meals. If he wants to add more meals, it must ask him to enter the index of the meal and add the index to the array of orders by invoking the addElement method. The method should keep on asking the user if he wants more meals and reading the indices of the meal until he enters that he does not want to add more meals. - The method must compute the total payment of the order by summing the prices of the ordered meal. - The method must invoke the incrementNumOrdered method for each ordered meal using its index. - At the end of the method, the order should be displayed by printing the ordered meals name-price each on a line, and print the total payment amount on the last line. d. Define the method isMealOrdered which takes an array of integers (that represents an order of meal indices) and an integer (that represents a meal index). The method should return true if the integer (meal) is found in the order and false otherwise. e. In your main method, perform the following in order: - Print the number of menus created. - Create an object of type Menu named menul using the no-arg constructor. - Create an object of type Menu named menu2 using the second constructor and pass menul as an argument. - Invoke the method makeAnOrder twice by passing menul in the first time and menu2 in the second.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY