Newer
Older
labs / tiddlers / content / review / java_exercises / _Review_Console Menu.md
@Mark George Mark George on 15 Jul 2021 533 bytes Add review exercises

Write a Java console program that displays a simple text-based menu in the console.

The menu should:

  1. Display a text menu with three options.

  2. Prompt the user to select one of the menu options.

  3. Use multiple if-else statements to display a message that relates to the selected option.

The following code can be used to read input from the console:

Scanner scanner = new Scanner(System.in);

// this will read an integer
int i = scanner.nextInt();

// this will read a string
String s = scanner.nextLine();