Advertisement
Archdevil

05. Login

Mar 8th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _05Login
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string username = Console.ReadLine();
  14.             string password = "";
  15.             for (int i = username.Length - 1; i >= 0; i--)
  16.             {
  17.                 password += username[i];
  18.             }
  19.             string currentPassword = Console.ReadLine();
  20.             int invalidPassAttempt = 1;
  21.             while (currentPassword != password)
  22.             {
  23.                 Console.WriteLine("Incorrect password. Try again.");
  24.                 invalidPassAttempt++;
  25.                 if (invalidPassAttempt == 4)
  26.                 {
  27.                     Console.WriteLine($"User {username} blocked!");
  28.                     return;
  29.                 }
  30.                 currentPassword = Console.ReadLine();
  31.             }
  32.            
  33.                 Console.WriteLine($"User {username} logged in.");
  34.            
  35.         }
  36.  
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement