Advertisement
AEassa

Untitled

Jul 2nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6.     const std::string PASSWORD = "bulletsfordemons";
  7.     const int MAX_TRIES = 5;
  8.     bool login_success = false;
  9.     std::string user_entry;
  10.     int cnt = 0;
  11.  
  12.     while (login_success == false && cnt < MAX_TRIES)
  13.     {
  14.         std::cout << "Please enter your password: " << std::endl;
  15.         std::cin >> user_entry;
  16.         ++cnt;
  17.  
  18.         if (user_entry == PASSWORD)
  19.         {
  20.             login_success = true;
  21.             std::cout << "You've entered the correct password. Welcome to the system." << std::endl;
  22.         }
  23.         else
  24.         {
  25.             std::cout << "INCORRECT PASSWORD!" << std::endl;
  26.         }
  27.     }
  28.  
  29.     if (cnt == MAX_TRIES && !login_success)
  30.     {
  31.         std::cout << "Nice try, but I'm not that easy to crack." << std::endl;
  32.     }
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement