Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Login
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             string username = Console.ReadLine();
  10.             string correctPassword = "";
  11.             string password = "";
  12.  
  13.             for (int letter = username.Length - 1; letter >= 0; letter--)
  14.             {
  15.                 correctPassword += username[letter];
  16.             }
  17.  
  18.             for (int i = 0; i < 4; i++)
  19.             {
  20.                 password = Console.ReadLine();
  21.  
  22.                 if (password == correctPassword)
  23.                 {
  24.                     Console.WriteLine($"User {username} logged in.");
  25.                     return;
  26.                 }
  27.  
  28.                 else if (i == 3)
  29.                 {
  30.                     break;
  31.                 }
  32.  
  33.                 else
  34.                 {
  35.                     Console.WriteLine($"Incorrect password. Try again.");
  36.                 }
  37.             }
  38.  
  39.             Console.WriteLine($"User {username} blocked!");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement