Using Input from a Document to find averages and show string output

I'm a beginner with programming and was given the following assignment:

The input file contains the names, locations, current enrollments, and current tuitions of schools in Ohio. In particular, all information
for one school is listed together. For example, in the input file, “OH-in.dat”, the first four lines indicate the name of the school (i.e.,
AntiochCollege), location of the school (i.e., YellowSprings), current enrollment of the school (i.e., 330), and current tuition of the
school (i.e., 27800). Then, the same information for other schools is followed in the file. In addition, the file contains *** to indicate
the end of data. (Note that you must use “OH-in.dat” file as the input file for the program.) Also note that there are no spaces in the
names of the schools, so you can safely use the >> operator to process input from the file.
Your program should behave as follows. Each of these tasks should be accomplished in the order listed. All output should appear on the
screen. Further, there should be at least two blank lines in between each section (that is, each task).

1) List the schools and the tuition of the schools in Cincinnati with tuition below 20000. Also list the number of schools that meet
these criteria.

2) Calculate and display the average tuition of schools with more than 10000 enrolled students. Indicate the tuition of BGSU and also
indicate if BGSU tuition is higher or lower than average.

3) Give the name and tuition of the three most expensive schools. You can assume that the top three schools have different tuitions
than all others (there are no "ties").

I think I have the first step right, but I'm confused on the other two. Specifically, How do I use the input from the file to find the average? How do I find the top three schools and list their names as output? I'd appreciate any assistance you can give. Thanks!
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// File Name	:	DrouillardJ_Prog3.cpp
// Description	:	
// Author		:	Drouillard, Joshua
// Date			:	10/26/15

#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
using namespace std;

int main()
{

	//declarations
	ifstream infile;
	int count1 = 0, count2 = 0, count3 = 0, tuition = 0, totalTuition = 0, avgTuition = 0, enrolledStudents = 0;
	string schoolName, location;
	const int tuitionBG = 15086;

	//task 1
	infile.open("OH-in.txt");
	infile >> schoolName;
	while (schoolName != "***")
	{
			infile >> location;
			infile >> enrolledStudents;
			infile >> tuition;

			if (tuition < 20000 && location == "Cincinati")
			{
				cout << schoolName <<endl;
				count1++;
				cout << count1 << endl;
			}

		infile >> schoolName;
	}
	// show how many colleges with tuition under 20,000 were found
	infile.close();

	//task 2
	infile.open("OH-in.txt");
	infile >> schoolName;
	while (schoolName != "***")
	{
		infile >> location;
		infile >> enrolledStudents;
		infile >> tuition;
		
		count2++;

		if (enrolledStudents > 10000)
		{
			for (int i = 1; i <= count2; i++)
			{
				totalTuition += tuition;
				avgTuition = totalTuition / count2;
				cout << "The average tuition is " << avgTuition << endl;
				cout << "BGSU's tuition is " << tuitionBG << endl;

				if (tuitionBG > avgTuition)
				{
					cout << "BGSU's tuition is higher than the average.";
				}
				else if (tuitionBG < avgTuition)
				{
					cout << "BGSU's tuition is lower than the average.";
				}
				else if (tuitionBG == avgTuition)
				{
					cout << "BGSU's tuition is equal to the average.";
				}
			}
		}

		infile >> schoolName;
	}

	infile.close();

	//task 3

	system("pause");
	return 0;
}
Please help. I feel like the more I try to fix it the worse I'm making it.
Topic archived. No new replies allowed.