Hey guys, my assignment is to rewrite this old program that I wrote by using various types of functions. The old program worked perfectly. it read the following file, and produced the table below it. The new program though, does not exit the loop, and surprisingly does not print anything on the output file. So its not even reading the tableheader function apparently.
I would appreciate some help. Thanks!
INPUT FILE:
Introduction to Computer Programming I
Toots Sweet
87 76 90 -1
Willy Nilly
73 63 64 70 -1
Phil O'Sophy
-1
Jill Quirk
90 80 70 -1
John Smith
100 90 87 100 -1
Al Bondy
50 56 30 60 -1
Barb Nelson
90 89 78 100 80 70 -1
Bob Brown
80 76 82 66 50 -1
Nancy Johnsen
90 90 -1
John Derikson
100 78 99 89 77 97 -1
ORIGINAL OUTPUT FILE:
======================================================================
Name Number of Tests Average Grade
----------------------------------------------------------------------
Toots Sweet 3 84.3 B
Willy Nilly 4 67.5 D
Phil O'Sophy 0 Error there were no scores for this student.
Jill Quirk 3 80.0 C
John Smith 4 94.2 A
Al Bondy 4 49.0 F
Barb Nelson 6 84.5 B
Bob Brown 5 70.8 C
Nancy Johnsen 2 90.0 B
John Derikson 6 90.0 B
----------------------------------------------------------------------
Class Average for 9 students is: 78.9
void Tableheader(ofstream& Ofile)
{Ofile<<"======================================================================"<<
"\nName Number of Tests Average Grade";
Ofile<<"\n----------------------------------------------------------------------";}
int count=0, Score=0;
char letter=0;
float Sum=0,Avg=0;
Ifile>>Score;
while (Score>=0)
{
Sum+=Score;
count++;
Ifile>>Score;
}
if (count!=0)
{
Avg=Sum/count;
Tsum+=Avg;
Tcount++;
}
if (count==0)
Ofile<<" "<<endl<<fixed<<left<<setw(20)<<student1+""+student2 <<"0"<<" Error there were no scores for this student.";
else
Ofile<<" "<<endl<<fixed<<setprecision(1)<<left<<setw(20)<<student1+" "+student2<<setw(15)<<count<<setw(15)<<Avg<<lettergrade(Avg);