im new to this programming stuff and I was wondering if someone could help me add a loop to my program?
cout << "What do you do?" "\n";
cout << "\n";
cout << "(Press Enter...)";
cin.ignore();
cout << "\n";
cout << "Stay in bed?" "\n";
cout << "Go to the bathroom?" "\n";
cout << "Go downstairs?" "\n";
cout << "\n";
string answer;
getline(cin, answer);
if (answer == "stay in bed", "Stay in bed")
{
cout << "You lay there, motionless. Silent.";
}
else if (answer == "go to the bathroom", "Go to the bathroom")
{
cout << "You get up and walk across the hall to the bathroom";
}
else if (answer == "go downstairs", "Go downstairs")
{
cout << "You get up and walk downstairs to the kitchen.";
}
else
{
cout << "That is not a valid answer...";
}
cin.ignore();
Heres the code. How should I add a loop to where when user enters something falling under the condition of "else", the loop returns to ask "What do you do?". Any help is greatly appreciated. And like I said Im very new to all of this so sorry if this question is so basic that its stupid...
Aucun commentaire:
Enregistrer un commentaire