Min/Max, Mean, Variance

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>

using namespace 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(const double 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(const double 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(const double 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;
}

What specifically do you need help with? You need to ask a question if you want an answer.
I need help making the functions for minMax, calcMean, and calcVarience. I'm not really sure how to do it using an external data file.
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.
my professor wants us to use a while-not-end-of-file loop
http://stackoverflow.com/q/5837639/1959975
http://stackoverflow.com/q/5605125/1959975
You may want to inform your professor that it is bad for many reasons. If he still requires you to do it, you'll have to write some excess workaround code but it should still work.
Topic archived. No new replies allowed.