Here is how I count the grades from the dat file.
while (line != null) //Whilst line is not empty
{
if (line == "A") //check if the line reads as A
{
gradeA++; //Incrememnt by one
counter++; //Add one to counter
}
else
if (line == "B") //check if the line reads as B
{
gradeB++; //Incrememnt by one
counter++; //Add one to counter
}
else
if (line == "C") //check if the line reads as C
{
gradeC++; //Incrememnt by one
counter++; //Add one to counter
}
else
if (line == "D") //check if the line reads as D
{
gradeD++; //Incrememnt by one
counter++; //Add one to counter
}
else
if (line == "E") //check if the line reads as E
{
gradeE++; //Incrememnt by one
counter++; //Add one to counter
}
else
if (line == "F") //check if the line reads as F
{
gradeF++; //Incrememnt by one
counter++; //Add one to counter
}
line = tr.ReadLine(); //now load the next line from grades.dat