nevenailievaa

05.Login

Jan 15th, 2023
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. //INPUT
  2. using static System.Net.Mime.MediaTypeNames;
  3.  
  4. string username = Console.ReadLine();
  5. string password = Console.ReadLine();
  6.  
  7. //CHANGEABLE
  8. int attempt = 0;
  9.  
  10. //ACTION
  11. //Reverse
  12. char[] cArray = username.ToCharArray();
  13. string reverseUsername = String.Empty;
  14. for (int i = cArray.Length - 1; i > -1; i--)
  15. {
  16.     reverseUsername += cArray[i];
  17. }
  18.  
  19. //OUTPUT
  20. while (attempt != 3)
  21. {
  22.     attempt++;
  23.     if (password != reverseUsername)
  24.     {
  25.         Console.WriteLine("Incorrect password. Try again.");
  26.         password = Console.ReadLine();
  27.     }
  28.     else
  29.     {
  30.         Console.WriteLine($"User {username} logged in.");
  31.         return;
  32.     }
  33. }
  34. Console.WriteLine($"User {username} blocked!");
Advertisement
Add Comment
Please, Sign In to add comment