Outputting scores

I am trying to figure out why this code just closes the window instead of displaying the results and I am kind of stuck with what I have. Please let me know if you see something with my loops that need changes to stay open so I can display the scores. Thanks for the help.

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
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

//Declaring Constants
const int ZERO = 0;
const int ONE_HUNDRED = 100;

int main()
{
	int firstExam, secondExam, thirdExam;

	cout << "Dr. DoLittle's Grading Program ..... (by Kirk Kelley)" << endl;
	cout << "Please enter in the score for the first exam: ";
	cin >> firstExam;
	cout << "Please enter in the score for the second exam: ";
	cin >> secondExam;
	cout << "Please enter in the score for the third exam: ";
	cin >> thirdExam;
	
	//declaring variable
	int homework;

	//declaring vector
	vector<int> scores;


	while (!cin.eof())
	{

		homework = EOF;

		cout << "\nEnter score for homework assignment (press Ctrl+Z to quit): ";

		cin >> homework;

		if (!cin.good())
			if (homework == EOF)
				break;
			else
			{
				cout << "\nInvalid Input. Entry must be an integer." << endl;
				cin.clear();
				cin.ignore(std::numeric_limits<streamsize> ::max(), '\n');
			}
		else
		{
			if (homework >= ZERO && homework <= ONE_HUNDRED)
			{
				scores.push_back(homework);
			}
			else
			{
				cout << "\nInvalid Input. Grade must be between 0-100." << endl;
				cin.clear();
				cin.ignore(std::numeric_limits<streamsize> ::max(), '\n');
			}
		}
	}
	for (unsigned int i = 0; i < scores.size(); i++)
	{
		cout << scores[i] << '\n';
	}
	return 0;
}
http://www.cplusplus.com/forum/beginner/1988/

Once you reach line 66, the console is going to close.
Last edited on
Topic archived. No new replies allowed.