// switch example #2 import javax.swing.*; public class switch_example2 { public static void main( String[] args ) { // Prompt the user to enter a number: String numString = JOptionPane.showInputDialog(null, "Pick a number from 1-6:", "Input Window Demo", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value int pick = Integer.parseInt(numString); System.out.println(" You picked a " + pick + "."); switch (pick) { case 1: System.out.println("You entered 1!\n"); break; case 2: case 3: System.out.println("You entered a 2 or a 3!\n"); break; case 4: case 5: case 6: System.out.println("You entered a 4, 5, or a 6!\n"); break; default: System.out.println("You did not enter an 1,2, 3, 4, 5 or 6!\n"); break; } /* end switch */ System.exit( 0 ); } // end main }