int loadArray(ifstream& infile, double data[], int arrayLimit);
int findMax(resist, numPts);
int findMin(resist, numPts);
int calcMean(resist, numPts);
int geomMean(resist, numPts);
int rmsAvg(resist, numPts);
int harmMean(resist, numPts);
void sortValues(int resist, int numPts);
int main()
{
double resist[MAXSIZE];//maxsize of the resist
int numPts = 0;//number of points
ifstream infile("HW9resist.txt");
if (!infile)
{
cout<<"Error: could not open file"<<endl;
infile.close();
return 1;
}
numPts = loadArray(infile,resist, MAXSIZE);
cout<<"The maximum value is"<<findMax(resist, numPts)<<endl;
cout<<"The minimum value is"<<findMin(resist, numPts)<<endl;
cout<<"The mean is"<<calcMean(resist, numPts)<<endl;
cout<<"The geometric mean is"<<geomMean(resist, numPts)<<endl;
cout<<"The rms average is"<<rmsAvg(resist, numPts)<<endl;
cout<<"The harmonic mean is"<<harmMean(resist, numPts)<<endl;
sortValues(resist, numPts);
cout<<"The sorted list of values is:";
for(int i = 0; i < numPts; i++)
{
cout<<resist[i]<<endl;
i++;
}
infile.close();
return 0;
}
int loadArray(ifstream& infile, double data[], int arrayLimit)
{
int numPts = 0;
while(numPts < arrayLimit && infile>>data[numPts])
{
numPts++;
}
if(numPts >= arrayLimit)
{
cout<<"Maximum number of data values reached"<<endl;
}
else if(!infile.eof())
{
cout<<"Error reading file"<<endl;
}
else
{
cout<<"End of file found"<<endl;
}
I wasnt trying to get anyone to do it for me i was just stuck and needed help. I filled everything out to the best of my ability and made other post because im not getting the answers i need.
You know that you can google Global variables and get your question answered within seconds, instead of posting the question here and wasting your and our time right?