Advertisement
Vlad_Savitskiy

Password

Apr 2nd, 2020
168
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.  
  3. namespace CSLightFirst
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int attemptCount = 3;
  10.             string password = "qwerty";
  11.             string userInput;
  12.  
  13.             Console.Write("Пожалуйста, введите пароль: ");
  14.             userInput = Console.ReadLine();
  15.  
  16.             while(attemptCount > 0)
  17.             {
  18.                 if (userInput == password)
  19.                 {
  20.                     Console.WriteLine("Добро пожаловать в личный кабинет");
  21.                     break;
  22.                 }
  23.  
  24.                 if (--attemptCount == 0)
  25.                 {
  26.                     Console.WriteLine("Доступ закрыт, повторите попытку входа завтра");
  27.                     break;
  28.                 }
  29.  
  30.                 Console.Write($"Пароль неверный, попробуйте ещё (осталось попыток: {attemptCount}): ");
  31.                 userInput = Console.ReadLine();
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement