#include #include using namespace std; int main() { //step0: declare some variables string guess; string password; password = "apple"; int numGuesses =0; //the number of times the user has guessed. //step1: Ask user to enter a password cout << "Please enter the password: " << endl; cin >> guess; //step2: check if they entered the correct password. //If so, congratulation, else, KEEP ASKING. //But, if they guess wrong 10 times, kick them out! while (guess != password && numGuesses <10) { numGuesses = numGuesses + 1; //or do: numGuess++; cout << "Wrong password! Please try again: " << endl; cin >> guess; } cout << "Ah, I see you finally made it out of" << endl; cout << " the while loop." << endl; if (numGuesses >= 10) { cout << "Sorry, too many wrong guess, you are locked out." << endl; } else { cout << "You got the password correct! Welcome!" << endl; } return 0; }