Write in C++ \"Whats the watts\" The data file Powcrl.dat is located on blackboa
ID: 3668003 • Letter: W
Question
Write in C++
"Whats the watts" The data file Powcrl.dat is located on blackboard and 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. In developing your program use symbolic constants NROWS and NCOLS to represent the number of rows and columns in the 2-D array used to store the values. Then write a program to: Compute and print the average power output over this ten week period. 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. 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 [] [NCOLS], int test row); 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.xxExplanation / Answer
include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
const int NCOL = 7;
const int NROW = 10;
const int MAX_POWER = 99999;
int main()
{
double min_power=MAX_POWER, power_out[NROW][NCOL];
unsigned int row, col;
ifstream power;
power.open("power1.dat");
for (row=0; row<NROW; row++)
for (col=0; col<NCOL; col++)
{
power >> power_out[row][col];
if (power_out[row][col] < min_power)
min_power = power_out[row][col];
}
cout << "Minimum power output was: " << min_power << endl;
for (row=0; row<NROW; row++)
for (col=0; col<NCOL; col++)
if (power_out[row][col] == min_power)
cout << "Week " << row << ", day " << col << " was a minimum power out day." << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.