/********************************************************************* * Author: Eric Heim * Date Created: 5/31/2011 * Course: CS0007 * Description: Shows the basic functionality of a switch statement * by having the user enter 1, 2, or 3 *********************************************************************/ import java.util.Scanner; public class SwitchStatement { public static void main(String[] args) { int entry; Scanner keyboard = new Scanner(System.in); System.out.print("Enter 1, 2, or 3: "); entry = keyboard.nextInt(); switch(entry) { case 1: System.out.println("You entered one."); break; case 2: System.out.println("You entered two."); break; case 3: System.out.println("You entered three."); break; default: System.out.println("You did not enter 1, 2, or 3!"); break; } } }