Source Code
Session4.java
import java.util.*;
public class Session4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String myName = ""; // Add your name
System.out.println("Session4 - " + myName);
// menu variables
boolean done = false;
String choice;
do {
// Menu
System.out.println("Menu");
System.out.println("E1 - Example 1");
// optionally, add new menu items
System.out.println("Q - Quit");
System.out.print("Choice: ");
choice = in.nextLine();
switch (choice) {
case "E1":
System.out.println("Example 1");
break;
case "E2":
System.out.println("Example 2");
break;
case "E3":
System.out.println("Example 3");
break;
case "E4":
System.out.println("Example 4");
break;
case "E5":
System.out.println("Example 5");
// exampleMethod() call
break;
case "E6":
System.out.println("Example 6");
break;
case "E7":
System.out.println("Example 7");
break;
case "E8":
System.out.println("Example 8");
break;
case "E9":
System.out.println("Example 9");
break;
case "E10":
System.out.println("Example 10");
break;
// quit and default cases
case "Q":
System.out.println("Quit");
done = true;
break;
default:
System.out.println("Invalid Choice");
break;
}
} while (!done);
}
// exampleMethod definition
// example6 method definition
// example7 method definition
// example8 method definition
// example9 method definition
// example10 method definition
}
Last updated