/* Menu2.java CIS 160 David G. Klick 2004-09-17 Demonstrates multi-branch selection (switch statement), the char data type, and some String methods */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Menu2 { public static void main(String[] args) throws IOException { BufferedReader kbd = new BufferedReader( new InputStreamReader(System.in)); String strIn; char choice; // This next instruction clears some space on the screen System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); System.out.println("Main menu\n"); System.out.println(" 1. (E)ncouragement\n"); System.out.println(" 2. (A)dvice\n"); System.out.println(" 3. The (t)ruth\n"); System.out.print("Please enter choice: "); strIn = kbd.readLine(); choice = strIn.toUpperCase().charAt(0); System.out.println(); switch (choice) { case '1': case 'E': System.out.println("Things could get worse."); break; case '2': case 'A': System.out.println("Don't eat anything bigger than your head."); break; case '3': case 'T': System.out.println("You can't handle the truth."); break; default: System.out.println("Invalid choice, moron!"); } System.out.println("\nHave a nice day."); } }