Im completely stuck on this project. My professor is making us use his variables and it's really confusing. We have to declare an array MAXSIZE that can hold 1000 measurements, and store the contents of a data file in the array. This is what I have so far:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
usingnamespace std;
/**
* computes the maximum and minimum values in the data set
* @param data - an array containing the measurements
* @param count - the number of measurements
* @param min - the minimum measurement
* @param max - the maximum measurement
*/
void minMax(constdouble data[ ], int count, double& min, double& max) {
}
/**
* computes the sample mean
* @param data - an array containing the measurements
* @param count - the number of measurements
* @return the mean of the set of measurements
*/
double calcMean(constdouble data[], int count) {
}
/**
* computes the sample variance
* @param data - an array containing the measurements
* @param count - the number of measurements
* @return the sample variance of the set of measurements
*/
double calcVariance(constdouble data[ ], int count) {
}
int main() {
string filename;
fstream inFile;
cout << "Enter the name of the data file>";
cin >> filename;
inFile.open (filename.c_str(), ios::in);
if (!inFile) {
cout << "Unable to open " << filename << " for input." <<endl;
return -1;
}
cout << "Descriptive Statistics" <<endl;
cout << "-----------------------------" <<endl;
cout << "N: " <<endl;
cout << "Min: " <<endl;
cout << "Max: " <<endl;
cout << "Range: " <<endl;
cout << "Mean: " <<endl;
cout << "Variance: " <<endl;
cout << "Standard Deviation: " <<endl;
return 0;
}
Between lines 51 and 53, you should read in the measurements from the file into an array, and keep track of how many measurements you read in so that when you read them all you know how many you have. Note: do not loop on EOF; instead, loop on the input operation.