okay this is what ive done today and it calculates the mean for the first row in the healthy.txt attachment i added earliear. I need it to do the rest of the 1999 rows as well...
Code:
#include<iostream.h>
#include<fstream.h>
void main()
{
//might need variables to store in the mean
float mean = 0.0;
float cell1= 0.0;
float cell2= 0.0;
float cell3= 0.0;
float cell4= 0.0;
float cell5= 0.0;
float cell6= 0.0;
float cell7= 0.0;
float cell8= 0.0;
float cell9= 0.0;
float cell10= 0.0;
//open up file
ifstream inFile;
inFile.open("healthy.txt");
//verify open was sucessful
if(!inFile.fail()) //ifopen did not fail
{
//read cell a1 through j1
inFile >> cell1 >> cell2 >> cell3 >> cell4 >> cell5 >> cell6 >> cell7 >> cell8
>> cell9 >> cell10;
//calculate the mean for ROW and place in mean variable
mean = (cell1+cell2+cell3+cell4+cell5+cell6+cell7+cell8+cell9+cell10)/10;
cout<<mean<<endl;
}//end if
else //open failed
cout<<"Error opening file."<<endl;
}//end main
now when i added in the EOF function like so...
Code:
//verify open was sucessful
if(!inFile.fail()) //ifopen did not fail
{
//read cell a1 through j1
inFile >> cell1 >> cell2 >> cell3 >> cell4 >> cell5 >> cell6 >> cell7 >> cell8
>> cell9 >> cell10;
while(!inFile.eof()){
//calculate the mean for ROW and place in mean variable
mean = (cell1+cell2+cell3+cell4+cell5+cell6+cell7+cell8+c ell9+cell10)/10;
cout<<mean<<endl;
inFile >> cell1 >> cell2 >> cell3 >> cell4 >> cell5 >> cell6 >> cell7 >> cell8
>> cell9 >> cell10;
}
}
it calculates all 2000 rows and displays them but it calculates them wrong. I checked with my trusty rusty calculator several times. Do you see anything wrong with my logic on getting the mean for each row?