C code help can someone help me with making a code If necess


C++ code help

can someone help me with making a code
If necessary, create a new project named Intermediate23 Project and save it in the Cpp81Chap12 folder. Also create a new source file named Intermediate23.cpp. Declare a seven-row, two-column int array named temperatures. The program should prompt the user to enter the highest and lowest temperatures for seven days. Store the highest temperatures in the first column in the array. Store the lowest temperatures in the second column. The program should display the average high temperature and the average low temperature. Display the average temperatures with one decimal place. Save and then run the program. Test the program using the data shown in Figure 12-19. Day HighestLowest 95 98 86 67 54 70 56 34 68 45 4 83 75 80 Figure 12-19

Solution

// C++ code

#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include <iomanip> // std::setprecision

using namespace std;

int main ()
{
   int ROW = 7;
   int COLUMN = 2;
int temperature[ROW][COLUMN];

double totalAvg = 0;
double highTempavg = 0;
double lowTempavg = 0;

for (int i = 0; i < ROW; ++i)
{
   cout << \"Enter High temperature for day \" << (i+1) << \": \";
   cin >> temperature[i][0];
   cout << \"Enter Low temperature for day \" << (i+1) << \": \";
   cin >> temperature[i][1];

   highTempavg = highTempavg + temperature[i][0];
   lowTempavg = lowTempavg + temperature[i][1];
   totalAvg = totalAvg + temperature[i][0] + temperature[i][1];
}

cout << \"\ Average high temperature: \" << highTempavg/ROW << endl;
cout << \"Average low temperature: \" << lowTempavg/ROW << endl;
cout << \"Average temperature: \" << setprecision (3) << totalAvg/(ROW*COLUMN) << endl;

return 0;
}

/*
output:

Enter High temperature for day 1: 95
Enter Low temperature for day 1: 67
Enter High temperature for day 2: 98
Enter Low temperature for day 2: 54
Enter High temperature for day 3: 86
Enter Low temperature for day 3: 70
Enter High temperature for day 4: 99
Enter Low temperature for day 4: 56
Enter High temperature for day 5: 83
Enter Low temperature for day 5: 34
Enter High temperature for day 6: 75
Enter Low temperature for day 6: 68
Enter High temperature for day 7: 80
Enter Low temperature for day 7: 45

Average high temperature: 88
Average low temperature: 56.2857
Average temperature: 72.1


*/

 C++ code help can someone help me with making a code If necessary, create a new project named Intermediate23 Project and save it in the Cpp81Chap12 folder. Als
 C++ code help can someone help me with making a code If necessary, create a new project named Intermediate23 Project and save it in the Cpp81Chap12 folder. Als

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site