Question: Fix the code so that: The hours when a brownout occurred You must store the voltage readings in an array. You may assume that all

Fix the code so that:

The hours when a brownout occurred

You must store the voltage readings in an array. You may assume that all of the values inputted are legal (i.e. 0 If there are no hours that meet one of the criteria you should print the string [none] (without the quotes).

The code is working, but the last part "If there are no hours that meet one of the criteria you should print the string [none] (without the quotes)." Should be added.

#include

void printHour10Mean(int voltage[], int n, double mean, double mean10) { printf("hours that vary >= 10%% from mean: "); int i = 0;

int first = 1; for(i = 0; i

if (diff > mean10) { if (first == 1) { printf("%d", (i+1)); first = 0; } else { printf(",%d", (i+1)); }

} } printf(" "); }

void printHour15MeanNeighbour(int voltage[], int n, double mean, double mean15) { printf("hours of neighbors that vary >= 15%% of mean: "); int i = 0;

int first = 1; for(i = 1; i

if (diff > mean15) { if (first == 1) { printf("(%d,%d)", i, (i+1)); first = 0; } else { printf(",(%d,%d)", i, (i+1)); } } } printf(" "); }

void printBrownOutHour(int voltage[], int n, double mean, double brownout) { printf("hours brownout occurred: "); int i = 0;

int first = 1; for(i = 1; i

if (diff

int main() { int n = 72; int voltage[n];

printf("EGRE245 Project #5 Spring 2017 - Yaqoub Alqallaf ");

int i; double mean = 0; for (i = 0; i

double mean10 = mean*.1; double mean15 = mean*.15; double brownout = 120*(1-.108); printf("Number of voltages: 72 "); printf("Mean voltage: %.2f (10%% of mean: %.2f; 15%% of mean: %.2f) ", mean, mean10, mean15); printf("Brownout threshold: %.2f ", brownout);

printHour10Mean(voltage, n, mean, mean10); printHour15MeanNeighbour(voltage, n, mean, mean15); printBrownOutHour(voltage, n, mean, brownout); }

The full instructions:

An electric power substation measures voltages hourly for 72 continuous hours before they send off a report to the manager. Write a C program to generate this report that reads in 72 integer voltage readings from standard input in order to determine:

the mean voltage over the time period

the hours at which the recorded voltage varies from the mean by more than 10%

any adjacent hours when the change from one reading to the next was greater than 15% of the mean

the hours when a brownout occurred

You must store the voltage readings in an array. You may assume that all of the values inputted are legal (i.e. 0

2 Sample Run

Sample run data:

120 119 119 120 117 119 120 120 120 120 120 120 120 120 120 120 0 0 120 120 120 120 120 120 120 122 121 122 121 121 120 120 120 120 100 120 120 120 120 120 107 102 104 118 120 120 120 120 120 120 120 120 120 119 120 119 119 121 120 120 120 120 120 120 120 104 106 120 120 119 120 120 

Fix the code so that: The hours when a brownout occurred You

Terminal tcsh 67X24 liberty cat proj5.dat 120 119 119 120 117 119 120 120 120 120 120 120 120 120 120 120 0 0 120 120 120 120 120 120 120 122 121 122 121 121 120 120 120 120 100 120 120 120 120 120 107 102 104 118 120 120 120 120 120 120 120 120 120 119 120 119 119 121 120 120 120 120 120 120 120 104 106 120 120 119 120 120 liberty cru/tmp acc proj5.c liberty tmp/% a. out proj5.dat EGRE 245 Project #5 Spring 2015 Dan Resler Number of voltages: 72 Mean voltage 115.26 (10% of mean 11.53; 15% of mean: 17.29) Brownout threshold: 107.04 hours that vary 10% from mean 17, 18,35,42 hours of neighbors that vary 15% of mean C16, 17), (18, 19 (34,35), C35,36) hours brownout occurred: 17,18,35,41, 42,43,66,67 liberty N/tmp/% Terminal tcsh 67X24 liberty cat proj5.dat 120 119 119 120 117 119 120 120 120 120 120 120 120 120 120 120 0 0 120 120 120 120 120 120 120 122 121 122 121 121 120 120 120 120 100 120 120 120 120 120 107 102 104 118 120 120 120 120 120 120 120 120 120 119 120 119 119 121 120 120 120 120 120 120 120 104 106 120 120 119 120 120 liberty cru/tmp acc proj5.c liberty tmp/% a. out proj5.dat EGRE 245 Project #5 Spring 2015 Dan Resler Number of voltages: 72 Mean voltage 115.26 (10% of mean 11.53; 15% of mean: 17.29) Brownout threshold: 107.04 hours that vary 10% from mean 17, 18,35,42 hours of neighbors that vary 15% of mean C16, 17), (18, 19 (34,35), C35,36) hours brownout occurred: 17,18,35,41, 42,43,66,67 liberty N/tmp/%

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!