daily pastebin goal
94%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace P05Login
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string username = Console.ReadLine();
  10.  
  11.             string password = "";
  12.  
  13.             string inputForPassword = Console.ReadLine();
  14.  
  15.             int counterOfTrials = 0;
  16.  
  17.             for(int i= username.Length - 1; i>=0; i--)
  18.             {
  19.                 password += username[i];
  20.             }
  21.  
  22.             if(inputForPassword == password)
  23.             {
  24.                 Console.WriteLine($"User {username} logged in.");
  25.             }
  26.  
  27.             while (inputForPassword != password)
  28.             {
  29.                 Console.WriteLine("Incorrect password. Try again.");
  30.                
  31.                 string trialsOfInputs = inputForPassword;
  32.                 inputForPassword = Console.ReadLine();
  33.  
  34.                 counterOfTrials++;
  35.                 if (counterOfTrials >= 3)
  36.                 {
  37.                     Console.WriteLine($"User {username} blocked!");
  38.                     return;
  39.                 }
  40.  
  41.                 if (inputForPassword == password)
  42.                 {
  43.                     Console.WriteLine($"User {username} logged in.");
  44.                 }
  45.  
  46.             }
  47.         }
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top