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.
#include <iostream>
#include <vector>
#include <cstdio>
usingnamespace std;
//Declaring Constants
constint ZERO = 0;
constint 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 (unsignedint i = 0; i < scores.size(); i++)
{
cout << scores[i] << '\n';
}
return 0;
}