So I am trying to write a program that asks the user for a name. If the user enter the right name the program ends but if the user were to enter the wrong name the program would enter a loop prompting the user to re-enter the name.
However I am not able to get the program to work! any help would be greatly appreciated
what im trying to do is get the user to enter a name, in this case the only name accepted is JustinWu. If the user enters the wrong name I want the program to loop and ask the user to re-enter their name.
I tried your suggestions, but the program still wont compile
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string acconName;
cout<<"Welcome to the Bank of Wonderland!"<<endl;
cout<<"Enter your Name: ";
cin>>acconName;
while (acconName!="JustinWu")
{
cout<<"\nSorry, " << acconName << " is an incorrect name. Re-enter name: ";
cin>>acconName;
}
cout << "\nWelcome " << acconName << "!" << endl;
system("pause");
return 0;
Welcome to the Bank of Wonderland!
Enter your Name:
Sorry, JustinW is an incorrect name. Re-enter name:
Sorry, JustnWu is an incorrect name. Re-enter name:
Welcome JustinWu!