TheBulgarianWolf

Login

Sep 24th, 2020
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. void Main()
  2. {
  3.     string username = Console.ReadLine();
  4.     string password = "";
  5.     string userInput = "";
  6.     for(int i = username.Length-1;i >= 0;i--)
  7.     {
  8.         password += username[i];
  9.     }
  10.     int counter = 0;
  11.  
  12.     while((userInput = Console.ReadLine())  != password)
  13.     {
  14.         if(userInput != password)
  15.         {
  16.            
  17.             if(counter == 3)
  18.             {
  19.                 Console.WriteLine($"User {username} blocked!");
  20.                 return;
  21.             }
  22.             Console.WriteLine("Login not successful! Incorrect password!Try again!");
  23.             counter++;
  24.         }
  25.        
  26.        
  27.     }
  28.    
  29.     if(userInput == password)
  30.         {
  31.             Console.WriteLine($"User {username} logged in.");
  32.            
  33.         }
  34. }
  35.  
Add Comment
Please, Sign In to add comment