anizko

05. Login

May 19th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 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 _5.Login
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string Username = Console.ReadLine();
  14.             string CorrectPassword = "";
  15.             int WrongPassword = 1;
  16.  
  17.  
  18.             for (int i= Username.Length-1; i>=0 ; i--)
  19.             {
  20.                
  21.                 CorrectPassword += Username[i];
  22.  
  23.             }
  24.  
  25.             string Password = Console.ReadLine();
  26.  
  27.             while(Password!= CorrectPassword && WrongPassword<=3)
  28.             {
  29.                 WrongPassword++;
  30.                 Console.WriteLine("Incorrect password. Try again.");
  31.  
  32.                 Password = Console.ReadLine();
  33.                
  34.             }
  35.             if (WrongPassword > 3)
  36.             {
  37.  
  38.                 Console.WriteLine($"User {Username} blocked!");
  39.             }
  40.             else
  41.             {
  42.                 Console.WriteLine($"User {Username} logged in.");
  43.             }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment