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
|
//PRIMARY LOOP
int loop(char grade[], int hours[], string clnam[], string crsem[], string crnum[], int& clnum, int& loopnum, string filename, int cap, course_taken course_taken[]) {
for ( ; loopnum < clnum; loopnum++) {
cout << "What was the name of the class?:\n";
cin.ignore();
getline (cin, clnam[loopnum]);
cout << "What about the semester?\n";
getline (cin, crsem[loopnum]);
cout << "Now the course number:\n";
getline (cin, crnum[loopnum]);
cout << "And the grade you received:\n";
cin >> grade[loopnum];
bool checker = 0;
while (checker == 0) {
if (*LONG ASS LIST OF CONDITIONALS*) {
checker = 1;
}
else {
//cin.clear();
cout << "That's not a grade. Try again:\n";
cin >> grade[loopnum];
}
}
cout << "Finally, enter the number of hours the class was worth:\n";
cin >> hours[loopnum];
checker = 0;
while (checker == 0) {
if (hours[loopnum] < 20 && hours[loopnum] > 0) {
checker = 1;
}
else {
//cin.clear();
//cin.ignore (100, '\n');
cout << "Gee golly gosh, I don't think you should be entering a value like that. Try again.\n";
cin >> hours[loopnum];
}
}
course_taken[loopnum].set(clnam[loopnum], crsem[loopnum], crnum[loopnum], grade[loopnum], hours[loopnum]);
}
write(filename, grade, hours, clnam, crsem, crnum, clnum);
read (filename, grade, hours, clnam, crsem, crnum, clnum, cap, course_taken);
return loopnum;
}
|