I'm having quite a difficult time with this program. I'm trying to write a program that calculates the average of the GPAs for male and female students. Each line of my file has an f or an m followed by a GPA. I have to use a sentinel controlled while loop, but I'm having a heck of a time. I'm not really sure what to do??

#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;

int main()

const int sentinel = -999;

ifstream inFile;
string grades;
int num;
int sum = 0;
int count = 0;

getline(inFile, grades);

cout << "Line 1: Enter the numbers ending with " << sentinel << endl;
cin >> num;
while (num != sentinel)
      sum = sum + num;
      cin >> num;

cout << "Line 7: The sum of the " << count << " numbers is " << sum << endl;

if (count != 0)
      cout << "Line 9: The average is " << sum / count << endl;
      cout << "Line 11: No input." << endl;

return 0;

>I'm not really sure what to do?

First, read from the file, not cin. Next, if your file has an f or m preceding the GPA, you'll need to read this character. Then, depending on which it was, you'd adjust one of the two running sums.