I made an input and an output file. Don't know what part of the code i'm doing wrong. but this is what I end up with on my output file with the wrong alphabet grade?? Also, I know I declared some wasteful variables.
b
Name: Fahman Khan
Test Score: 85.00ac
Name: Addision Walker
Test Score: 90.00c
Name: Tony Adver
Test Score: 70.00
//Declare all the variables
string firstname, lastname;
double testscores;
int averagegrade;
char alphabetgrade;
int sum;
sum=0;
int counter=0;
//Open the input file that will read the student name and 3 scores
ifstream fin;
fin.open("student.txt");
//If file does not open, what happens
if (!fin)
{
cout<<"ERROR";
}
//open the outputfile
ofstream fout;
fout.open("data.out");
fout<<fixed<<showpoint<< setprecision(2);
// How to display the name
cout<<"Processing Data";
fin>> firstname >>lastname;
fin>>testscores;
while (fin)
{
//taly how many students
sum=sum+testscores;
counter++;
if( testscores>=90)
{ fout<<"ac";}
elseif (testscores>=80)
{ fout<<"b";}
elseif (testscores>=70)
{ fout<<"c";}
else
{ fout<<"F";
}
//on the output data
fout<< "\nName: " <<firstname;
fout<<" " <<lastname;
fout<<"\nTest Score: "<<testscores;
fin>>firstname >> lastname >>testscores;
}
fin.close();
fout.close();