// Helene Martin, CSE 142 // Prompts the user for several days' worth of high temperatures. // Reports their average and the number of days about average. // Temperature values are needed to calculate the average and to // count those above average. Perfect use of arrays! 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(); int sum = 0; int[] temps = new int[days]; for (int i = 1; i <= days; i++) { System.out.print("Day " + i + "'s high temperature: "); int high = console.nextInt(); sum += high; temps[i - 1] = high; } double average = (double)sum / days; int count = 0; for (int i = 0; i < temps.length; i++) { if (temps[i] > average) { count++; } } System.out.println("Average temp: " + average); System.out.println(count + " days above average"); } }