// DecideDestination.java // CS 101 class example // demonstrates nested conditionals public class DecideDestination { public static void main (String[] args) { // check number of arguments if (args.length != 2) { System.out.println("Usage: java DecideDestination <\"sunny\"|\"rainy\"> "); } else { // get command-line parameters String weather = args[0]; int temperature = Integer.parseInt(args[1]); // decide destination String destination = ""; if (weather.equals("sunny")) { if (temperature >= 80) { destination = "beach"; } else { destination = "park"; } } else if (weather.equals("rainy")) { destination = "mall"; } else { destination = "computer lab"; } // announce destination System.out.println("Go to the " + destination); } // end of else block (number of arguments ok) } // end of main method }