/* Lab 3, problem 2: a complete solution -- version 1*/ import java.util.Scanner; class AdvisorComplete { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print ("Is it raining outside? (Y/N) "); /* Read the input as a String object and call chatAt(0) to return the very first character of that String object. */ char reply = (scan.nextLine()).charAt(0); System.out.print ("Enter outside temperature: "); int temp = scan.nextInt(); // case 1: the outside temperature is less than 60 if (temp <= 60) { if (reply == 'Y' || reply == 'y'){ System.out.print ("Wear a raincoat."); System.out.println (".. and don't forget an umbrella."); } else System.out.println ("Wear an overcoat."); } else { if (temp < 70) { System.out.print ("Wear a jacket."); if (reply == 'Y' || reply == 'y') System.out.println (".. and don't forget an umbrella."); } else if (reply == 'Y' || reply == 'y') System.out.println ("Get an umbrella."); else System.out.println ("Perfect weather -- nothing to worry about."); } } }