Answer:
Following are the code to the given question:
#include<iostream>//header file
#include<iomanip>//header file
using namespace std;
int main()//main method
{
double temperatures[7][2];//defining a double array temperatures
double lowAvg=0, highAvg=0;//defining a double variable
for(int i = 0;i<7;i++)//defining loop to input the value
{
cout<<"Enter day "<<(i+1)<<" highest temperatures: ";//print message
cin>>temperatures[i][0];//input highest temperatures value
cout<<"Enter day "<<(i+1)<<" lowest temperatures: ";//print message
cin>>temperatures[i][1];//input lowest temperatures value
}
cout << fixed << setprecision(1);//using the setprecision method
for(int i = 0;i<7;i++)//defining loop to calculating the Average of the
{
highAvg += temperatures[i][0];//holding highest value
lowAvg += temperatures[i][1];//holding lowAvg value
}
cout<<"Average high temperature = "<<highAvg/7<<endl;//calculate amd print highest temperature Average
cout<<"Average low temperature = "<<lowAvg/7<<endl;//calculate amd print lowest temperature Average
return 0;
}
Output:
Please find the attached file.
Step-by-step explanation:
- In this code, a 2D array "temperatures" and two-variable "highAvg, lowAvg" as double is declared, that uses the two for loops.
- In the first loop, it uses an array to input the value from the user-end.
- In the second loop, it uses the double variable that calculates the average value of the temperature.