// CSE 142, Summer 2008, Helene Martin // Prompts the user for several days' temperatures. // Reports the average temperature and how many days were above average. import java.util.*; public class Weather { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("How many days' temperatures? "); int[] temps = new int[console.nextInt()]; int total = 0; for(int i = 0; i < temps.length; i++) { System.out.print("Day " + (i + 1) + " 's temperature: "); temps[i] = console.nextInt(); total = total + temps[i]; } double average = total * 1.0 / temps.length; System.out.println("Average temp = " + average); // days above average ("warm") int warm = 0; for(int i = 0; i < temps.length; i++) { if(temps[i] > average) { warm++; } } System.out.println(warm + " days were above average."); } }