Question: Apply the 3 file format: 1 header file and 2 source files. Implement guard code in a header file Write a program that processes numbers,
Apply the file format: header file and source files. Implement guard code in a header file
Write a program that processes numbers, corresponding to student records read in from a file, and writes the required results to an output file see main Your program should define the following functions:
pts double readdouble FILE infile Reads one double precision number from the input file. Note: You may assume that the file only contains real numbers.
pts int readinteger FILE infile Reads one integer number from the input file. pts double calculatesum double number double number double number double number double number Finds the sum of number number number number and number and returns the result.
pts double calculatemean double sum, int number Determines the mean through the calculation sum number and returns the result. You need to check to make sure that number is not If it is the function returns we will assume that we are calculating the mean of positive numbers otherwise it returns the mean.
pts double calculatedeviation double number, double mean Determines the deviation of number from the mean and returns the result. The deviation may be calculated as number mean.
pts double calculatevariance double deviation double deviation double deviation double deviation double deviation int number Determines the variance through the calculation: deviationdeviationdeviationdeviationdeviation number and returns the result. Hint: you may call your calculatemean function to determine the result.
pts double calculatestandarddeviation double variance Calculates the standard deviation as sqrt variance and returns the result. Recall that you may use the sqrt function that is found in math.h
pts double findmax double number double number double number double number double number Determines the maximum number out of the five input parameters passed into the function, returning the max.
pts double findmin double number double number double number double number double number Determines the minimum number out of the five input parameters passed into the function, returning the min.
pts void printdouble FILE outfile double number Prints a double precision number to the hundredths place to an output file.
pts A main function that does the following this is what the program
does!!!:
Opens an input file "input.dat" for reading; Opens an output file "output.dat" for writing;
Reads five records from the input file inputdat; You will need to use a combination of readdouble and readinteger function calls here!
Calculates the sum of the GPAs; Calculates the sum of the class standings; Calculates the sum of the ages;Calculates the mean of the GPAs, writing the result to the output file outputdat; Calculates the mean of the class standings, writing the result to the output file outputdat;
Calculates the mean of the ages, writing the result to the output file outputdat;
Calculates the deviation of each GPA from the mean Hint: need to call calculatedeviation times
Calculates the variance of the GPAs
Calculates the standard deviation of the GPAs, writing the result to the output file outputdat;
Determines the min of the GPAs, writing the result to the output file outputdat; Determines the max of the GPAs, writing the result to the output file outputdat;
Closes the input and output files ie input.dat and output.dat
Expected Input File Format real numbers only:
For this assignment you will be required to read five records from the "input.dat" file. Each record will have the following form:
Student ID# an digit integer number
GPA a floatingpoint value to the hundredths place
Class Standing where is a freshmen, is a sophomore, is a junior, and
is a senior all integers Age a floatingpoint value
Example data for student record in the file could be as follows:
IV Expected Results:
The following sample session demonstrates how your program should work.
Assuming input.dat stores the following records:
Your program should write the following to output.dat: NOTE: you only need to output the numbers, the text is for demonstration purposes only.
GPA Mean
Class Standing Mean Age Mean
GPA Standard Deviation GPA Min
GPA Max
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
