// Helene Martin, CSE 142 // Calculates average temperature over a series of user-supplied // values and reports how many temperatures were above average // Required storing all temperatures as they were given -- perfect // place for an array. 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 days = console.nextInt(); double total = 0; double[] temps = new double[days]; for (int i = 1; i <= days; i++) { System.out.print("Day " + i + "'s temp? "); double temp = console.nextDouble(); temps[i - 1] = temp; total += temp; } double average = total / days; int count = 0; for (int i = 0; i < temps.length; i++) { if (temps[i] > average) { count++; } } System.out.println("Average: " + average); System.out.println("Above average: " + count); } }