kisame1313

1.3.8.1.2

Jul 14th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4.     {
  5.     static void Main()
  6.         {
  7.         /*
  8.          * Сделайте счётчик неверных вводов пароля,
  9.          * и при достижение числа 5, завершите программу.
  10.          */
  11.  
  12.         int attempts = 5;
  13.  
  14.         while(true)
  15.             {
  16.             string password = Console.ReadLine();
  17.             if (password == "admin")
  18.                 {
  19.                 Console.WriteLine("Secret message");
  20.                 break;
  21.                 }
  22.             else
  23.                 {
  24.                 attempts--;
  25.                 Console.WriteLine("Wrong passport, you have only {0} attempts left", attempts);
  26.                 if (attempts==0)
  27.                     {
  28.                     Console.Clear();
  29.                     Console.WriteLine("\tYou have no more attempts\n\t\t Bye!");
  30.                     break;
  31.                     }
  32.                 }
  33.             }
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment