Source Code
Session5.java
import java.util.*;
public class Session5 {
public static void main(String[] args) {
String myName = ""; // add your name
System.out.println("Session 5 " + " - " + myName);
// Menu
System.out.println("Menu");
System.out.println("E1 - Example 1");
// setup Scanner
Scanner in = new Scanner(System.in);
System.out.print("Choice: ");
String choice = in.nextLine();
// switch choices
switch (choice) {
case "E1":
System.out.println("Example 1");
// call greeting method
break;
case "E2":
System.out.println("Example 2");
// call greeting method
break;
case "E3":
System.out.println("Example 3");
// call mantra method
break;
case "E4":
System.out.println("Example 4");
// call sumNumbers method
break;
case "E5":
System.out.println("Example 5");
// call checkDivisibility method
break;
case "E6":
System.out.println("Example 6");
// call earnings method
break;
default:
System.out.println("Invalid Choice");
}
}
// define greeting method
// define mantra method
// define sumNumbers method
// define checkDivisbility method
// define earnings method
}
Session5v2.java
Last updated