Hi, I'm trying to write a program that reads one line of data from three different files each time it goes through the loop. Here's some of my code.
//open the three data files and assign each to a variable
ifstream r("rightside.txt");
r>>right;
ifstream l("leftside.txt");
l>>left;
ifstream f("frontside.txt");
f>>front;
//for loop to read one line of each file and determine the glucose reading
while (!r.eof())
{
A=(abs(right-left));
B=(abs(front-right));
C=(abs(left-front));
if (A<5&&B<5)
{cout<<"\nThe glucose measurement in the right side is "<<right<<endl;
glucose=glucose+right;
number++;}
else
cout<<"\nThe right side tester is clogged!"<<endl;
if (A<5&&C<5)
{cout<<"The glucose measurement in the left side is "<<left<<endl;
glucose=glucose+left;
number++;}
else
cout<<"The left side tester is clogged!"<<endl;
if (B<5&&C<5)
{cout<<"The glucose measurement in the front side is "<<front<<endl;
glucose=glucose+front;
number++;}
else
{cout<<"The front side tester is clogged!"<<endl;}
average=avg(glucose, number);
cout<<"The average glucose measurement is "<<average<<endl;
fout<<average;
//call the next line of the text file
r>>right;
l>>left;
f>>front;
}
My values in each of the data files range from about 150-200 but every time I try to print out values for right or anything, very large numbers come up. When I run the program, it says all of the testers are clogged.