I am in an intro to c++ class. I am being asked to calculate the average GPA from a text file. The text file is 2 columns: the first is the class (freshman, sophomore, junior, senior) and the second is the GPA. Each line is a random student from one of the classes. I have to find the GPA of each class. I am having trouble writing a loop that searches for only freshman to calculate the GPA. I don't want you to write my homework. Just need assistance with this one part!
Well, the way I would go about doing this as I read in the info from the text file I use an if statement to test what class they are in and then depending on what class I add their GPA to a total for that class and add one to a counter for their class. When done looping through the file I would do the calculations and output the results. This should help set you in the right direction.