// Zorah Fung, CSE // This program prompts user for several days' temperatures and prints out // the average and the number of days over the avereage temperature import java.util.*; public class Temperatures { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("How many days' temperatures to input? "); int days = console.nextInt(); int[] allTemps = new int[days]; double total = 0; for (int i = 1; i <= days; i++) { // We start at 1 because prompts start at Day 1 System.out.print("Day " + i + " temp? "); allTemps[i - 1] = console.nextInt(); // Must use i - 1 because indices start at 0 total += allTemps[i - 1]; } double average = total / days; System.out.println("The average is " + average); int totalDaysAboveAverage = 0; for (int i = 0; i < allTemps.length; i++) { if (allTemps[i] > average) { totalDaysAboveAverage++; } } System.out.println("There were " + totalDaysAboveAverage + " above the average"); } }