With my program, it is supposed to collect a student's 5 grades and get the average. I've figured out that part with assistance. The second part is to ask if there are any more students using a do while loop to repeat the process if there are. If there are no more students, to end the program, the user should enter a -1 to end the program. But I'm having trouble with repeating it and entering the -1 to end the program. If you could explain what I'm doing wrong, I would really appreciate it. With my output, it will correctly run the first entry, but it goes wrong when My output with the second part is: "Would you like to enter an additional student? -1
Enter Student's First and Last Name:
Enter Grade 1:" And it doesn't allow me to enter a second student's name, it just automatically goes to "Enter Grade 1:" Any guidance would be greatly appreciated.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string choice;
do {
float grades, sum = 0;
string studentName;
cout << "Enter Student's First and Last Name: ";
getline(cin, studentName);
cout << endl;
for (int i = 1; i <= 5; i++)
{
cout << "Enter Grade " << i << ": ";
cin >> grades;
sum += grades;
}
cout << endl;
cout << studentName << "'s grade average is: " << sum / 5;
cout << endl;
cout << "Would you like to enter an additional student (-1 to terminate)? ";
cin >> choice;
cin.ignore(1000, '\n');
} while (choice != "-1");
}