Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Power Plant Data. The data file power1.dat contains a power plant output in mega

ID: 2901291 • Letter: P

Question

Power Plant Data. The data file power1.dat contains a power plant output in megawatts over a period of 10 weeks. Each row of data contains 7 floating-point numbers that represent 1 week's data. In developing the following programs, use symbolic constants NROWS and NCOLS to represent the number of rows and columns in the array used to store the data.


Write a program to print a report that lists the average power output for the first day of the week, then for the second day of the week, and so on. Print the information in the following format:


Day x: Average Power Output in Megawatts: xxxx.xx


power1.dat information:

207 301 222 302 22 167 125

367 60 20 111 301 499 434

211 62 441 192 21 293 316

401 340 161 297 441 117 206

448 111 370 220 264 444 207

212 313 204 222 446 401 337

213 20 444 321 320 335 313

162 137 265 44 370 315 322

150 218 234 384 283 199 204

204 245 287 298 302 288 297

Explanation / Answer

#include <iostream>

#include <fstream>

int main()

{

ifstream file("power1.dat");

if(!file)

{

cout<<"could not open the file";

return;

}

float A[10][7];

float x=0.0;

for(int i=0;i<10;i++)

{

for(int j=0;j<7;j++)

{

file>>x;

A[i][j]=x;

}

}

x=0;

for(int i=0;i<10;i++)

{

x+=A[i][0];

}

cout<<"Day 1: Average Power Output in Megawatts: "<<x<<endl;

x=0;

for(int i=0;i<10;i++)

{

x+=A[i][1];

}

cout<<"Day 2: Average Power Output in Megawatts: "<<x<<endl;

x=0;

for(int i=0;i<10;i++)

{

x+=A[i][2];

}

cout<<"Day 3: Average Power Output in Megawatts: "<<x<<endl;

x=0;

for(int i=0;i<10;i++)

{

x+=A[i][3];

}

cout<<"Day 4: Average Power Output in Megawatts: "<<x<<endl;

x=0;

for(int i=0;i<10;i++)

{

x+=A[i][4];

}

cout<<"Day 5: Average Power Output in Megawatts: "<<x<<endl;

x=0;

for(int i=0;i<10;i++)

{

x+=A[i][5];

}

cout<<"Day 6: Average Power Output in Megawatts: "<<x<<endl;

x=0;

for(int i=0;i<10;i++)

{

x+=A[i][6];

}

cout<<"Day 7: Average Power Output in Megawatts: "<<x<<endl;

return 0;


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote