// directions_using_if.java --- using character entry followed by if/else import javax.swing.JOptionPane; public class DirectionsIf { public static void main(String[] args) { char direction; String cAsString; cAsString = JOptionPane.showInputDialog (null, "Enter N, E, S, or W"); direction = cAsString.charAt(0); if ((direction == 'N') || (direction =='n')) System.out.println ("You are heading north."); else if ((direction == 'S') || (direction == 's')) System.out.println ("You are heading south!"); else if (( direction == 'E') || (direction == 'e')) System.out.println ("You are heading east."); else if ((direction == 'W') || (direction == 'w')) System.out.println ("You are heading west."); else System.out.println ( direction + " is invalid. Where do you think you are going?"); System.exit (0); } }