Write a Java program that asks the user for several days\' temperatures and calc
ID: 655288 • Letter: W
Question
Write a Java program that asks the user for several days' temperatures and calculates the average temperature for that period and how many days were above average.
First, ask the user how many days he wants to calculate the average for. Second, create an array with that number and ask for the temperature of each day. Store the temperatures in the array. Finally, find the average temperature and the number of days above that average. Print the results to the screen.
- The array size will be inputted by the user (use Scanner). Please make sure it accomodates any value a user might put (100 or even 10000000, etc)
- Please make sure output starts printing at Day 1 and not Day 0.
- make a method called arrayAvg that accepts as an argument an array of numbers and returns the average of the numbers in that array.
- average and temperatures are double
- array size and number of days above the average temperature s int
Output:
Explanation / Answer
import java.util.Scanner; public class NumberAboveAverage { /** * @param args */ public static void main(String[] args) { System.out.println("Enter number of days of temperature to calculate:"); Scanner keyboard = new Scanner(System. in); int day = keyboard.nextInt(); int[] temperature = new int[day]; System.out.println("Enter " + day + " temperatures to calculate."); for(int i=0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.