Question: Write a program that uses a two - dimensional array to store the highest and lowest temperatures for each month of the year. The program
Write a program that uses a twodimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest temperatures for the year. Your program must consist of the following functions:
Function getData: This function reads and stores data in the twodimensional array.
Function averageHigh: This function calculates and returns the average high temperature for the year.
Function averageLow: This function calculates and returns the average low temperature for the year.
Function indexHighTemp: This function returns the index of the highest high temperature in the array.
Function indexLowTemp: This function returns the index of the lowest low temperature in the array.
These functions must all have the appropriate parameters.
Your twodimensional array is rows and columns. Each row is a month. Column is the low temperature and column is the high temperature.
You must create functions in addition to main. They must be named: getData, averageHigh, averageLow, indexHighTemp, indexLowTemp
getData will first read the low temperatures, then the high temperatures. Pass the array as a parameter
averageLow and averageHigh are caluculating an integer average NOT a floating point average. Make these functions return their respective average
indexLowTemp and indexHighTemp should also return an integer the index of the row with the lowest or highest temperature. This index can be used to get the highest or lowest temperature from the two dimensional array
In main you need to print lines:
Average high temperature: followed by the average high
Average low temperature: followed by the average low
Highest temperature: followed by the highest temperature
Lowest temperature: followed by the lowest temperature
These values need to be read from a file to avoid user input
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
