Hi everyone. I'm working on a program but I'm stuck on this one part that I cannot figure out. In this lab we are supposed to prompt the user for how many times they want to enter in records and after that number the program should quit. However my program seems to be stuck in a loop and never quits even after the number entered has been exceeded. I've been looking through my code and cannot figure out what I've done wrong. If anyone could help me out I'd greatly appreciate it.
Is there anyway of getting rid of the count inside the loop but keep the continuous prompt that I've got right now? Everything I've tried keeps causing my code not to compile properly.
So I got rid of the break with 0 is entered that was on line 58. Everything besides that looks correct to me though. I would greatly appreciate it if someone could give me a hint on how to break the input after count iterations.
while (true)
{
// prompt user for input
cout << "Enter the name [Last, First]: ";
getline(cin, aStudent.name);
cout << "Enter the Student ID: ";
cin >> aStudent.id;
cin.ignore(1000, 10);
while (true)
{
cout << "Enter the GPA: ";
cin >> aStudent.gpa;
cin.ignore(1000, 10);
if (aStudent.gpa >= 0 && aStudent.gpa <= 5) break;
cout << "GPA must be between 0.0 and 5.0" << endl;
}
while (true)
{
cout << "Enter the gender [M/F]: ";
cin >> aStudent.gender;
cin.ignore(1000, 10);
aStudent.gender = toupper(aStudent.gender);
if (aStudent.gender == 'M' || aStudent.gender == 'F') break;
cout << "Gender must be M or F." << endl;
}
cout << endl;
// add record to list
student.push_back(aStudent);
}