//********************************************************* // Mean and Standard Deviation // // Given a file of data, this program calculates and // displays the mean and the standard deviation. // // YOUR NAME GOES HERE // D. Searls // Asbury College // Oct 2006 //********************************************************* #include #include #include #include #include using namespace std; void readAndProcessInput( ); double mean( ); double stdDev( ); void displayResults( ); //********************************************************* // M A I N D R I V E R //********************************************************* int main() { ifstream inputFile; string filename, nameOfData; int n; double sumX, sumXSqr; cout << "STATISTICAL ANALYIS\n\n"; cout << "Name of the input file: "; cin >> filename; cout << endl; inputFile.open(filename.c_str()); if(!inputFile.fail()) { readAndProcessInput(inputFile, nameOfData, n, sumX, sumXSqr); inputFile.close(); displayResults(nameOfData, mean(n, sumX), stdDev(n, sumX, sumXSqr)); } else { cout << "Could not open the input file named '" << filename << endl; } return 0; } //--------------------------------------------------------- // readAndProcessInput // // Preconditions: the specified input file has been // opened successfully and contains no data errors. // // Postconditions: the name of the data set, the number of // data values, the sum of the data values, and the sum // of the squares of the data values will be returned. // // PARAMETER USAGE COMMENTS GO HERE //--------------------------------------------------------- void readAndProcessInput( ) { } //--------------------------------------------------------- // mean // // Precondition: the number of values is greater than 0. // // Postcondition: the mean will be returned as the function // value. // // PARAMETER USAGE COMMENTS GO HERE //--------------------------------------------------------- double mean( ) { } //--------------------------------------------------------- // stdDev // // Precondition: the number of values is greater than 0. // // Postcondition: the standard deviation will be returned // as the function value. // // PARAMETER USAGE COMMENTS GO HERE //--------------------------------------------------------- double stdDev( ) { } //--------------------------------------------------------- // displayResults // // Display the description of a set of numeric data, the // mean of the data values, and the standard deviation of // the data values. // // PARAMETER USAGE COMMENTS GO HERE //--------------------------------------------------------- void displayResults( ) { }