// Kyle Thayer, 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); // promt user for the number of days System.out.print("How many days?"); int days = console.nextInt(); // create an array of size "days" int[] allTemps = new int[days]; double total = 0; // ask user for the temp for each of the days for (int i = 1; i <= days; i++) { // We start at 1 because prompts start at Day 1 System.out.print("Day " + i + " temp? "); int temp = console.nextInt(); total += temp; // cummulative sum // store the temp into the array // eg. store day 1 into array element 0 (allTemps[0]) // and day 2 into array element 1 (allTemps[1]) allTemps[i - 1] = temp; } // find and print the average temp double average = total / days; System.out.println("The average is " + average); int aboveAvgCount = 0; // loop over each of the days in the array for(int i = 0; i < days; i++){ // check the current day's temp (allTemps[i]) against the average if(allTemps[i] > average){ aboveAvgCount++; // cummulative sum } } System.out.println("Number of days above average: " + aboveAvgCount); } }