Advertisement
Guest User

Untitled

a guest
Sep 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05_Password
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. string userName = Console.ReadLine();
  10. string userPassword = Console.ReadLine();
  11. string password = "";
  12. int reverseName = userName.Length - 1;
  13. int Counter = 0;
  14.  
  15. for (int i = reverseName; i >= 0; i--)
  16. {
  17. password += userName[i];
  18.  
  19. }
  20. while (true)
  21. {
  22. if (userPassword == password)
  23. {
  24. Console.WriteLine($"User {userName} logged in.");
  25. break;
  26. }
  27. else if (Counter >= 3)
  28. {
  29. Console.WriteLine($"User {userName} blocked!");
  30. break;
  31. }
  32. else
  33. {
  34. Console.WriteLine("Incorrect password. Try again.");
  35. Counter++;
  36. }
  37.  
  38. }
  39.  
  40.  
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement