Write a C++ program that estimates the average weather temperatures for the State of California for four (4) days in the month of May 2021.
The temperature data (°C) provided in each day for each time interval (6:00 AM to 12:00 PM) is shown in this table, and Figure 1 displays the example output that the software will produce:
Day/Hour-Hour
|
6-7
|
7-8
|
8-9
|
9-10
|
10-11
|
11-12
|
Day 1
|
17.2
|
18.1
|
21.5
|
24.3
|
25.5
|
26.0
|
Day 2
|
15.3
|
17.4
|
19.5
|
20.2
|
22.1
|
23.5
|
Day 3
|
16.1
|
18.5
|
19.0
|
19.8
|
21.2
|
22.4
|
Day 4
|
18.0
|
18.9
|
19.4
|
22.6
|
23.8
|
24.7
|
The program shall allow user to enter the data for six (6) time intervals. The program shall then display the hourly weather temperatures in tabular format (column: time interval, row: day) with the average temperatures on the interval 6:00 AM to 12:00 PM in each respective day. Following is the description of the program:
a) The program uses a1-dimensional array to store the day and a2-dimensional array to store the hourly temperatures for the six (6) intervals of each day of the month May 2021 usingpointer notations.
b) One void function named enterData() is defined to enter the information for 6 intervals in four (4) iterations.
c) One function named calcAvgTemps() is defined to calculate and returns a double value of the average temperature for each day. The function takes two (2) arguments. The function shall be called in a loop in your main() function.
d) One function named displayData() is defined to display all values stored in the 2-dimensional array after (c) has been calculated. This function shall be called through main().
You are given the partial codes below. Complete the code to achieve the output in Figure 1.
#include
#include
#include
using namespace std;
const int ROW = 4;
const int COL = 7;
//prototype
void enterData();
double calcAvgTemp();
void displayData();
string day[] = {"Day 1", "Day 2", "Day 3", "Day 4"};
int main()
{
double hourly_temps[ROW][COL];
double avg, sum;
//function call to enter data
for (int k = 0; k <>
{
sum = 0.0;
//function call here to calculate average
}
cout <>
//function call to display
return 0;
}
void enterData() //
{
cout <><><><><><>
<><><><><><><><><>
<>
//loop through user entry
}
void displayData() //
{
cout <><><><><><><><><><><><><><><><>
//loop through display data
}
double calcAvgTemp() //
{
double average, sum = 0.0;
//loop through accumulate total
//calculate average
return average;
}