/* Menu1.java CIS 160 David G. Klick 2004-09-17 Demonstrates multi-branch selection (switch statement) */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Menu1 { public static void main(String[] args) throws IOException { BufferedReader kbd = new BufferedReader( new InputStreamReader(System.in)); int 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. Encouragement\n"); System.out.println(" 2. Advice\n"); System.out.println(" 3. The truth\n"); System.out.print("Please enter choice (1-3): "); choice = Integer.parseInt(kbd.readLine()); System.out.println(); switch (choice) { case 1: System.out.println("Things could get worse."); break; case 2: System.out.println("Don't eat anything bigger than your head."); break; case 3: System.out.println("You can't handle the truth."); break; default: System.out.println("Invalid choice, moron!"); } System.out.println("\nHave a nice day."); } }