1st
Welcome: <full name>
Enter Password (1…2…3):
Note: You only have 3 attempts to enter the correct password.
IF WRONG PASSWORD: “Password incorrect! Please try again!”
IF CORRECT PASSWORD: “Password accepted!”
#1
int getPassword()
{
string name = "Harlem Shake";
int attempts;
string password;
cout << "Welcome: ";
getline(cin, name);
cout << "Enter the TOP SECRET passcode: ";
getline(cin, password);
for (attempts = 0; attempts < 3; attempts++)
{
if (password == "password") break;
cout << "Password accepted!";
else
cout << "Password incorrect! Please try again!”;
} // for
return attempts;
} // getPassword
2nd
Welcome to C++ Program Examples
Choose an activity:
IF CHOICE IS MORE THAN 15 or 0: “Invalid! Would you like to try again? (Y/N)”
IF ‘N’: Go back to first program.
#2
int activity()
{
int choice;
int x;
cout << "Welcome to C++ Program Examples ";
cout << "Choose an activity: ";
cout << "1-15";
getline(cin, choice);
for (x = 0; x < 15; x++)
{
if (choice =< 15) break;
else
cout << "Invalid! Would you like to try again? (Y/N)”;
} // for
}
here's my attempt. i badly needed your help guys.
Last edited on
0th
Make an attempt to actually write my homework before i ask in forums.
sorry, will you please help me. :(