Learn to initialize and iterate through multi-dimensional arrays
Subsection13.1.1Overview
In this exercise, you will work with a Java program that simulates a restaurant menu. A 2D array stores multiple dishes, each of which are put in 3 different categories: appetizers, entrees, and desserts. You must implement displayMenu and displayCategory. These methods are responsible for displaying the entire menu and specific categories of the menu, respectively.
Subsection13.1.22D Array
The menu 2D array is an array of String, where each sub-array represents a category of the menu. The first element of each sub-array is the name of the category.
menu[0][0] contains "Appetizers", menu[1][0] contains "Entrees" and menu[2][0] contains "Desserts".
The subsequent elements in each sub-array are the food items that belong to that category.
For example, in the Entrees category, menu[1][1] is "Steak", menu[1][2] is "Stir-Fry" and menu[1][3] is "Porkchops".
Here is a visual representation of the menu 2D array:
Table13.1.1.
Appetizers menu[0][0]
Deviled Eggs menu[1][1]
Nachos menu[1][2]
Salad menu[1][3]
Entrees menu[1][0]
Steak menu[2][1]
Stir-Fry menu[2][2]
Porkchops menu[2][3]
Dessert menu[2][1]
Key-Lime Pie menu[3][1]
Raspberry Tarts menu[3][2]
Sundae menu[3][3]
Subsection13.1.3Instructions
Implement the displayMenu method.
This method should iterate through the menu array and print all their categories along with their respective dishes.
Each dish should be printed on a new line and each category should be visually separated in the output.
Implement the displayCategory method.
This method accepts the menu 2D array and an integer category, which represents the index of the category to be displayed (0 for Appetizers, 1 for Entrees, 2 for Desserts).
displayCategory will display the chosen category and its dishes in the same format similar to displayMenu, but only for the specified category.