Question
Write a program to calculate the average temperature for the year and determine the hottest month of the year. In your main method, the program
Write a program to calculate the average temperature for the year and determine the hottest month of the year. In your main method, the program should collect the user input of the average Fahrenheit temperatures for each of the 12 months of a year into an array. The average temperature for January will go into the 1st index position of the array, February will go into the 2nd index position, etc.
Your main method should then call a method named averageTemp, passing the entire array of temperatures to this method as the only argument. The averageTemp method should compute the average of the numbers stored in the array passed to it and return the average to the caller.
Your main method should then call a method named getHotMonth, passing the entire array of temperatures to this method as well. The getHotMonth method should use the array to find the index position of the month with the hottest temperature. If there is a tie between two months, the method should return the array index position of first month to reach the hottest temperature.
Once main receives both the average and index position in the array of the hottest month, it should call a method named displayResults to display the average and hottest month to the user. The method displayResults will accept two arguments, the average temperature and the index position in the array of the hottest month. The final output of the program should say something like, The average temperature for the year was 45.7 degrees F with July being the hottest month.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started