This is part of a larger program and this is the only part that I can't get down. Right now, it runs fine once through, but telling it yes to repeat the loop at the end does not allow the user to input a new name for student once the loop repeats. How can I allow for name to be inputted again when the loop repeats? Any help is appreciated.
#include <iostream>
using namespace std;
int main ()
{
string name;
char choice;
do
{
cout << "What is the student's name?" << endl;
getline (cin, name);
cout << "Want to enter the data again? (y/n)" << endl;
cin >> choice;
while ((choice != 'y') && (choice != 'Y') && (choice != 'n') && (choice != 'N'))
{
cout << "Please enter a valid choice" << endl;
cin >> choice;
}
}
while ((choice == 'y') || (choice == 'Y'));
getchar();
return 0;
}