Guest User

Untitled

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