i need to know how many times the while loop is done.

``````while (myin)
{
myin >> name;
cout << name ;
myin >> num1 >> num2 >> num3;
cout << "     " << fixed << setprecision(0)<< num1  << "  "<< num2 << "   "<< num3 ;
average = (num1 + num2 + num3)/3;

cout << " " << fixed << setprecision(2)<< average ;
if ( average >= 90)
cout << "     A";
else if( average > 80)
cout << "     B";
else if( average > 70)
cout << "     C";
else if( average > 60)
cout << "     D";
else
cout << "     F";

cout << endl;
}
``````

i have multiple name and numbers so this repeats.

i want to know why last one is repeated?

also, i need to get an average of all of the averages, how can i do it?

``````int counter=0;

while(...)
{
...
...
...
counter++
}

cout << "The while() loop executed " << counter << " times.";``````
``````int counter=0;

while(...)
{
...
...
...
counter++
}

cout << "The while() loop executed " << counter << " times.";``````

YOu are awsome Thanks!!!

but why does my program repeat the last string?

I have a feeling you may have place program output inside of a loop.

Let us see ye' code.

I have a feeling you may have place program output inside of a loop.

Let us see ye' code.

``````counter = -1;
while (myin)
{
while (myin)
{
myin >> name;
cout << name ;
myin >> num1 >> num2 >> num3;
cout << "     " << fixed << setprecision(0)<< num1  << "  "<< num2 << "   "<< num3 ;
average = (num1 + num2 + num3)/3;

cout << " " << fixed << setprecision(2)<< average ;
if ( average >= 90)
cout << "     A";
else if( average > 80)
cout << "     B";
else if( average > 70)
cout << "     C";
else if( average > 60)
cout << "     D";
else
cout << "     F";

cout << endl;
counter++;
}

}
cout << "The class average is " << endl;
cout << "There are " << counter <<" students\n";
``````

its a program to calculate the average and grade it.

also, how do i get the average of average?

i am running low on time because i need to turn this in by 12:00.