Strange coding error

Hello, I am coding a program that reads from a text file of multiple rows of numbers made up of 4 columns meant to represent 4 tests taken by multiple students in one classroom.
After reading a line, the program is then supposed to calculate the average of each students and then give them a letter grade. I coded it to do so.
The problem is although the average is calculated without a problem the letter grade of the first student won't show up. Is there an error I overlooked?
Here's the code:
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
ifstream calcGrades;
calcGrades.open ("grades.txt");

int test1, test2, test3, test4;
int studentNum = 1;


while(calcGrades.good())
{
calcGrades >> test1 >> test2 >> test3 >> test4;
int average = (test1 + test2 + test3 + test4)/4;
char letterGrade;
if(average<60)
letterGrade='F';
if(average<=60 && average<70)
letterGrade='D';
if(average>=70 && average<80)
letterGrade='C';
if(average>=80 && average<90)
letterGrade='B';
if(average>=90)
letterGrade='A';
cout << "Student " << studentNum << "'s average is " << average << " they currently have a " << letterGrade << "." << endl;
studentNum++;
}

return 0;
}

And here's the content of the file it reads from:
44 55 77 88
79 88 100 99
77 99 98 99
100 88 89 100
55 56 40 77
100 100 99 95
88 84 87 88
96 97 99 100
30 44 77 55
79 77 88 0
54 52 60 77
88 77 88 77
44 77 10 95

Thank you for any help given, I've been agonizing over this and
I just can't see what went wrong.
You've got a typo if(average<=60 && average<70) it should be >= instead of <=
However that's unnecessary http://www.cplusplus.com/doc/tutorial/control/ (if else)
using `else' would simplify your conditions
1
2
3
4
if(average<60)
   letterGrade='F';
else if(average<70)
   letterGrade='D';
Thank you so much! It works just fine now. I guess sometimes it's the simplest slip ups some of us miss.
Topic archived. No new replies allowed.