desito07

Login

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