/** * Demonstrates a nested if with all nests on the else branch * Allows user to choose their favorite weather * @author Pete Nordquist * @version 180121 - uses TextIO */ public class WeatherChooser { public static void main(String[] args) { // declare an int to hold value from the user int i; // read int from user System.out.print("Your int from 1 to 5> "); i = TextIO.getlnInt(); System.out.println("You chose the following weather:"); if (i == 1) System.out.println("sun"); else if (i == 2) System.out.println("rain"); else if (i == 3) System.out.println("snow"); else if (i == 4) System.out.println("sleet"); else if (i == 5) System.out.println("hail"); else System.out.println("You did not enter a valid int."); } }