Question: Java --- Write a method to summarise daily tempratures. The details are given as follow. - The method will receive an array of doubles. Each
Java ---
Write a method to summarise daily tempratures. The details are given as follow.
- The method will receive an array of doubles. Each number in the array represents the temperature of a day.
- If there are less than 10 temperatures recorded, the method will not perform any calculation. Instead, it will print a message "Insufficient data".
- If there are 10 or more temperature recorded, the method will calculate:
-- the average temperature
-- the highest temperature
-- the number of cool days in which the temperatures are 20 or below
-- the number of warm days in which the temperatures are 21 to 30 (inclusive)
-- the number of hot days in which the temperatures are 31 and above.
- Upon completion, the method will print the following:
-- the number of cool days
-- the number of warm days
-- the number of hot days
-- the average temperature
-- the highest temperature
You may assume the array is not empty. You can make use of the following code snippet to write your answer:
---------------------------------------------
public static void getSummary (double [ ] temperatures)
{
//write your code here
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
