Asked to write a program to access data file called \"performance.txt\" Your pro
ID: 3639849 • Letter: A
Question
Asked to write a program to access data file called "performance.txt"Your program should load the information of 25 temperature values into an array and then ask the user to enter in values for the temperature limits (i.e. lower and upper bounds) that are allowable. Then we make a function call using the array as well as the temperature lower and upper bounds as the arguments for the function called operation:
The function will determine if the machine is running within the lower and upper bounds of normal operation by assigning an integer of eith 0 for running within spec, -1 for running below spec or 1 for running above spec, and write the determined integer into a new array. This function will then write this new array into a data file called "machine_op.txt" with a void returned (nothing returned) to the main program.
The function prototype is given as:
void operation(double temp[], double low_bound, double high_bound, int npts);
Things to program:
2. main program loads a data file and inputs that information into an array
3. main program prompts for user input of allowable temperature range (lower and upper bounds)
4. the function operation checks each element of the array against the user-entered allowable temperature range, assign an integer of either 0 , -1, or 1.
5. function operation will save the determined integer 0,-1, or 1 into a new array of the same size (ie 25 elements) and then write the resulting array into a data file called machine_op.txt
Explanation / Answer
#include using namespace std; void operation(double temp[], double low_bound, double high_bound, int npts); int main() { ifstream fin; double t[25],l,u; int i; fin.open("performance.txt"); if(!fin.is_open()) { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.