Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 If there are no hours that meet one of the criteria you should print the string [none] (without the quotes).

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 

image text in transcribed

Fix the code so that it can print out None when you enter this, or similar data:

120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120

#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); }

liberty tmp/% 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 tmp/96 gcc 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 (16, 17), (18, 19), (34,35), (35,36) hours brownout occurred: 17, 18,35,41,42,43,66, 67 liberty tmp%

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago