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.
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.
// prompt user for input
cout << "Enter the name [Last, First]: ";
cout << "Enter the Student ID: ";
cin >> aStudent.id;
cout << "Enter the GPA: ";
cin >> aStudent.gpa;
if (aStudent.gpa >= 0 && aStudent.gpa <= 5) break;
cout << "GPA must be between 0.0 and 5.0" << endl;
cout << "Enter the gender [M/F]: ";
cin >> aStudent.gender;
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
Topic archived. No new replies allowed.
You are using a version without Ads of this website. Please, consider donating: