I'm not sure if I understood that. I just wanna specify where to start reading the data from(Line 6)!!! lol. I know I didn't put these (marked red) in the right places.. where do i put them?
Code:
#include<iomanip.h>
#include<fstream.h>
#include<stdlib.h>
#define Max 8
main()
{ int ID[Max], Test[Max], C, CountA=0, CountB=0, CountC=0, CountD=0, CountF=0; char Grade;
ifstream IStudent("IStudent.dat");
char line[80];
for(C=0;C<Max;C++)
{ IStudent>>ID[C]>>Test[C];
IStudent.getline(line,80);
if(Test[C]<100 && Test[C]>=90)
{Grade='A'; CountA=CountA+1;}
else if(Test[C]<90 && Test[C]>=80)
{Grade='B'; CountB=CountB+1;}
else if(Test[C]<80 && Test[C]>=70)
{Grade='C'; CountC=CountC+1;}
else if(Test[C]<70 && Test[C]>=60)
{Grade='D'; CountD=CountD+1;}
else if(Test[C]<60 && Test[C]>=0)
{Grade='F'; CountF=CountF+1;}
else
{cout<<"Invalid Grade"<<endl;}
}
cout<<CountA<<"As"<<endl;
cout<<CountB<<"Bs"<<endl;
cout<<CountC<<"Cs"<<endl;
cout<<CountD<<"Ds"<<endl;
cout<<CountF<<"Fs"<<endl;
system("PAUSE");
return 0;
}
The Data File I'm reading from is
Code:
8 Records in File
ID Test Score
-------------------------------------------------------
123 97
234 54
345 77
456 65
567 87
678 69
789 84
890 76