Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Practice modularization Objective of this activity:- converting given code to modularised code menu.java package lecture4; import java.util.Scanner; public class Menu { public static void main(String[]

  1. Practice modularization

Objective of this activity:- converting given code to modularised code

menu.java

package lecture4;

import java.util.Scanner;

public class Menu {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int menuSel;

System.out.println("Menu");

System.out.println("1. Enter data");

System.out.println("2. Display data");

System.out.println("3. Exit");

System.out.println("Enter selection:");

menuSel = in.nextInt();

switch(menuSel){

case 1: System.out.println("Menu istem 1");

break;

case 2: System.out.println("Menu item 2");

break;

case 3: System.out.println("Exiting....");

break;

default: System.out.println("Invalid selection!");

}

in.close();

}

}

  • Create a method to display menu that will display the menu which is given in file and ask to enter their selection and return that selection to calling method. Call this method in main method where there is a need to print menu.
  • Move the switch case to a separate method which will take menuSel as input and print necessary details.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago