Source Code
Session8.java
import java.util.*;
public class Session8 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String myName = ""; // Add your name
System.out.println("Session 8 - " + 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");
example1();
break;
case "E2":
System.out.println("Example 2");
example2();
break;
case "E3":
System.out.println("Example 3");
example3();
break;
case "E4":
System.out.println("Example 4");
example4();
break;
case "E5":
System.out.println("Example 5");
example5();
break;
case "E6":
System.out.println("Example 6");
example6();
break;
case "E7":
System.out.println("Example 7");
example7();
break;
// quit and default cases
case "Q":
System.out.println("Quit");
done = true;
break;
default:
System.out.println("Invalid Choice");
break;
}
} while (!done);
}
// example1 method definition
public static void example1() {
}
// example2 method definition
public static void example2() {
}
// example3 method definition
public static void example3() {
}
// example4 method definition
public static void example4() {
}
// example5 method definition
public static void example5() {
}
// example6 method definition
public static void example6() {
}
// example7 method definition
public static void example7() {
}
}
Counter.java
// class header
// private instance variable(s)
// Constructor
// accessor method(s)
// mutator method(s)
Dice.java
import java.util.*;
// class header
public class Dice {
// private instance variable
// Constructor
// roll method()
// assign faceValue to a random number
// getFaceValue method
// toString method returns a string representation of this die.
BankAccount.java
// header
// private instance variables
// constructors
// no argument constructor
// one argument constructor
// two argument constructor
// three argument constructor
// methods
// deposit method
// withdraw method
// getBalance method
// toString method returns a string representation of this die.
Student.java
import java.util.*;
public class Student {
// private instance variables
// Constructor
// Getter and Setter for 'firstName'
// Getter and Setter for 'age'
// Getter and Setter for 'hobbies'
// Method to add a hobby
// Method to remove a hobby
// Method to count the number of hobbies
// Method to check if a specific hobby exists
// Method to print all hobbies
// toString method
}
Last updated