Advertisement
AEassa

Untitled

Jul 1st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string username = "";
  8.     string password = "";
  9.     bool success = false;
  10.     int tries = 0;
  11.  
  12.     while (!success && tries < 2)
  13.     {
  14.         cout << "Enter username: ";
  15.         cin >> username;
  16.  
  17.         cout << "Enter password: ";
  18.         cin >> password;
  19.  
  20.         if (username == "doomguy")
  21.         {
  22.             if (password == "killalldemons")
  23.             {
  24.                 cout << "Welcome, Doom Slayer!" << endl;
  25.                 success = true;
  26.             }
  27.             else
  28.             {
  29.                 cout << "INVALID CREDENTIALS!" << endl;  
  30.             }
  31.         }
  32.        
  33.         if (username == "billyblaze")
  34.         {
  35.             if (password == "killallnazis")
  36.             {
  37.                 cout << "Welcome, B.J.!" << endl;
  38.                 success = true;
  39.             }
  40.             else
  41.             {
  42.                 cout << "INVALID CREDENTIALS!" << endl;
  43.             }
  44.         }
  45.  
  46.         ++tries;
  47.     }
  48.  
  49.     cout << "Goodbye!" << endl;
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement