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

Use the numbers from the power plant in this file:powerFinal.txt (Links to an ex

ID: 671870 • Letter: U

Question

Use the numbers from the power plant in this file:powerFinal.txt (Links to an external site.)

This file contains the daily power delivered by a certain power plant over 10 weeks, for a total of 70 data points. The days are organized from Sunday through Saturday (just like a calendar).

-------------------------

Read this data into an array and perform the following:

1.    Compute and print the average power output over this period of time by day-of the week.

2.    Print the following text/data to the screen and to a new data file that you will create named "powerByDay.txt":

Daily Average Power
Sun     Mon    Tue     Wed    Thu     Fri      Sat
---------------------------------------------------------
123.4 123.4 123.4 123.4 123.4 123.4 123.4

c language

Explanation / Answer

I have check the result manuly . it is correct.

Program

#include<stdio.h>
int main()
{
FILE *inputfile;
FILE *outputfile;
inputfile=fopen("powerFinal.txt","r");
outputfile=fopen("powerByDay.txt","w");
int i=0,j=0;
float weeks[7];
float temp;
for(i=0;i<7;i++)
weeks[i]=0.0f;
for(i=0;i<10;i++)
{
for(j=0;j<7;j++)
{
fscanf(inputfile,"%f",&temp);
weeks[j]=weeks[j]+temp;
}
}

fprintf(outputfile,"Daily Average Power ");
fprintf(outputfile,"Sun Mon Tue Wed Thu Fri Sat ");
for(i=0;i<7;i++)
{
weeks[i]=weeks[i]/7;
fprintf(outputfile,"%.2f ",weeks[i]);
}
fclose(inputfile);
fclose(outputfile);

return 0;
}

Result:

Daily Average Power
Sun   Mon   Tue   Wed   Thu   Fri   Sat
359.43 359.71 282.14 388.29 282.14 415.86 418.86

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