// Tyler Rigsby, CSE 142 // Prompts for temperatures and reports statistics about them // Sample output: // // How many days' temperatures to input? 5 // Day 1 temp: 83 // Day 2 temp: 85 // Day 3 temp: 54 // Day 4 temp: 74 // Day 5 temp: 86 // // Average temperature: 76 // High temperature: 86 // Low temperature: 54 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(); if (days > 0) { System.out.print("Day 1 temp: "); int temp = console.nextInt(); int sum = temp; int max = temp; int min = temp; for (int i = 2; i <= days; i++) { System.out.print("Day " + i + " temp: "); temp = console.nextInt(); sum = sum + temp; if (temp > max) { max = temp; } min = Math.min(min, temp); } System.out.println("Average temperature: " + Math.round(1.0 * sum / days)); System.out.println("High temperature: " + max); System.out.println("Low temperature: " + min); } } }