EOF SECOND LOOP??? Incorrect output?

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



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  
	//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";}
		
			else if (testscores>=80)
			{	fout<<"b";}
			else if (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();
Can anyone please help me with this issue?
Anyone??? :(
Not sure what you are asking.

The grades seem to agree with the testscores.

1
2
3
4
5
6
7
8
9
10
11
b
Name: Fahman Khan
Test Score: 85.00

ac
Name: Addision Walker
Test Score: 90.00

c
Name: Tony Adver
Test Score: 70.00

Topic archived. No new replies allowed.