The power consumed by a heater can be calculated by the equation p = vi where p
ID: 3581848 • Letter: T
Question
The power consumed by a heater can be calculated by the equation p = vi where p = power (watts) v = voltage (volts) i = current (amperes) Write a program called PowerPC that will create and display the contents of a text file called HEATER POWER.TXT. The program should calculate the power consumed by various types of heaters. Prompt the user to enter the following data Each record should be written to the text file until the user enters a"Phi" for the Heater ID Number to terminate the input process. The file should then be closed. DO NOT TERMINATE. THE PROGRAM. Reopen the text file you produced above to create the following report for each entry in the file: Maximum Power: X.XX Total Number of Heaters: XXX Status: XXXXX Each report shows the Heater ID Number and Manufacturer Name once per Manufacturer. Any Voltage that is below 5 volts should he marked by an asterisk (*). The program should compute the power for each heater model using the voltage and current entered. If the computed power falls below 100 W the program should tag that power value with an asterisk (*) before and after the power value. Max power gets the * tag when it exceeds 200 W the Status is "Validated" if the maximum power is above 150 W, "Revaluate" if the maximum power is 120 W to 150 W and "Inactive "if below 120W. The total number of records processed from the text file should be displayed at the end of the program. You must create functions to perform the following as a minimum: Phase I open the file, prompt for user input, write the data to the HEATER POWER.TXT file for each record and then close the file.Explanation / Answer
if(voltage <5.0) { char temp[10]; strcat(temp,"*"); strcat(temp,voltage); strcat(temp,"*"); voltage=temp;
if(power <100) { char temp[10]; strcat(temp,"*"); strcat(temp,power); strcat(temp,"*"); power=temp;
else if (power >=120 && power <=150) { printf(" status = revaluate");}
else{ printf(" status = Inactive"); }
}
printf("heater_id manufacture_name model_id voltage current power"); while (fread (&input, sizeof(struct customer), 1, infile)) heater_id=input.heater_id; manufacture_name=input.manufacture_name; model_id= input.model_id; voltage=input.voltage; current=input.current; power=voltage*current; if(voltage <5.0) { char temp[10]; strcat(temp,"*"); strcat(temp,voltage); strcat(temp,"*"); voltage=temp;
if(power <100) { char temp[10]; strcat(temp,"*"); strcat(temp,power); strcat(temp,"*"); power=temp;
printf (heater_id " " manufacture_name " " model_id " " voltage " " current " " power); printf(" " Maximum Power=%d, power); if(power>150){ printf(" status = validated");} else if (power >=120 && power <=150) { printf(" status = revaluate");}
else{ printf(" status = Inactive"); }
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.