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

The data file Power1.dat contains a power plant output in Megawatts over a ten w

ID: 3669993 • Letter: T

Question

The data file Power1.dat contains a power plant output in Megawatts over a ten week period. Each row of data contains 7 numbers that represent 1 week’s data. Create a C++ program, using nrows and ncols. Write a program to:

1) Compute and print the average power output over this ten week period.

2) Print the day of the week and the number of the week on which the minimum power output occurred. If there are several days print them all.

3) Write a function to compute and return the average value of a row of the 2-D array to be inputted by the user. This represents the average over an entire week.

Use the following function prototype:

double Week_Average(double test_array[][7], int test_row, int nrows, int ncols);

where test_array is the local variable to store the 2-D array and test_row is the value of the row to average inputted by the user.

Use your function to print a report that lists the average power output for the first week, second week, and so on. Print the information in the following format:

Week 1: Average Power Output in Megawatts : xxxx.xx

Week 2: Average Power Output in Megawatts : xxxx.xx . . .

Explanation / Answer

Program is given below

#include<iostream>
using namespace std;

double Week_Average(double test_array[][7], int test_row, int nrows, int ncols)
{
   int i;
   double sum = 0;
   double average;
   for(i = 0; i < ncols; i++)
   {
       sum += test_array[test_row][i];
   }
  
   average = sum/ncols;
  
   return average;
  
}

int main()
{
   double power_array[10][7] = {
{207,301,222,302,22,167,125},
{367,60,120,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},
{21,313,204,222,446,401,337},
{213,208,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}
};

   for(int i = 0; i<10; i++)
   {
       cout<<"Week "<<i+1<<":"<<" Average Power Output in Megawatts : "<<Week_Average(power_array, i, 10, 7)<<endl;
   }
}

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