// dice_using_switch import javax.swing.*; public class dice_using_switch { public static void main( String[] args ) { // Prompt the user to enter a number: String numString = JOptionPane.showInputDialog(null, "Roll the die!! (1-6):", "Input Window Demo", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value int roll = Integer.parseInt(numString); System.out.println(" You rolled a " + roll + "."); switch ( roll ) { case 1: System.out.println("You rolled a one! Try again! \n"); break; case 2: System.out.println("You rolled a two! Too bad! \n"); break; case 3: System.out.println("You rolled a three! Better luck next time! \n"); break; case 4: System.out.println("You rolled a four! Sorry! \n"); break; case 5: System.out.println("You rolled a five! Way to go!!\n"); break; case 6: System.out.println("You rolled a six! I guess you win ...\n"); break; default: System.out.println("This is some wierd die! \n"); } // end switch System.exit( 0 ); // terminate application } // end main }