// directions_using_switch.java import javax.swing.JOptionPane; public class directions_using_switch { public static void main(String[] args) { char direction; String cAsString; cAsString = JOptionPane.showInputDialog (null, "Enter N, E, S, or W"); direction = cAsString.charAt(0); switch (direction) { case 'N': case 'n': System.out.println ("You are heading north."); break; case 'S': case 's': System.out.println ("You are heading south."); break; case 'E': case 'e': System.out.println ("You are heading east."); break; case 'W': case 'w': System.out.println ("You are heading west.."); break; default: System.out.println ( direction + " is invalid. Where do you think you are going?"); } //end of switch System.exit (0); } }