Machine Problem File Reading

I'm working on my homework for my online introductory programming class and honestly I got a little behind so I'm struggling trying to figure out all the machine problems, especially since the textbook isn't very helpful. I'm trying to figure out how to get my program to read the data file and then store them into the variables I've declared.

This is the part of the problem that I'm currently struggling with: "The data file is arranged with the information for each applicant on a separate line. Your program must process the data until the end of file is reached, at which time the program must print out the total number of applicants and the number of acceptances to each school. The data file should be created by you. Create the file and store it in the same project folder as your program."

The input file looks something like this:
L 4.0 600 650 N
M 3.9 610 520 N
L 3.8 590 600 N
L 3.0 600 600 Y
L 3.4 600 600 N
etc..

the variables from left to right are which school is being applied to, gpa, math SAT, verbal SAT and if parents are alumnus.

Here's what I've got so far which I'm sure is all wrong.

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
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
	ifstream inFile ("app.txt");

	string line;

	char school, alumnus;
	double gpa;
	int mathSAT, verbalSAT;
	int combinedSAT=0;

	cout << "Acceptance to College by Cailin Ferguson" << endl;

	if (inFile.is_open())
	{
		while (getline(inFile, line))
		{
			cout << line << '\n';
		}
		inFile.close();
	}
	
	combinedSAT = mathSAT + verbalSAT;

	if (school == 'L')
	{
		cout << "Applying to Liberal Arts";
		if (alumnus == 'Y')
		{
			if (gpa >= 3.0)
			{
				if (combinedSAT >= 1000)
				{
					cout << "Accepted to Liberal Arts";
				}
			}
			else if (alumnus == 'N')
			{
				if (gpa >= 3.5)
				{
					if (combinedSAT >= 1200)
					{
						cout << "Accepted to Liberal Arts";
					}
				}
			}
		}

	}
}


Any help pushing me in the right direction is greatly appreciated!
One way to read the data from the file:
1
2
3
4
5
6
7
8
9
10
11
if (inFile.is_open ())
  {
    while (inFile >> school >> gpa >> mathSAT >> verbalSAT >> alumnus)
    {
      // only to check if we read it correctly.
      cout << school << '\t' << gpa << '\t' << mathSAT << '\t';
      cout << verbalSAT << '\t' << alumnus << '\n';
      // use your input here
    }
    inFile.close (); // not needed - stream will close itself
  }
That worked, thank you!
Topic archived. No new replies allowed.