AlexRaynor

2.8 Programm under password

Aug 26th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 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 ConsoleApp13
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string password = "";
  14.             int tryCount = 0;
  15.             while (tryCount < 5)
  16.             {
  17.                 Console.WriteLine("Enter password");
  18.                 password = Console.ReadLine();
  19.                 tryCount++;
  20.                 if (password == "qwerty")
  21.                 {
  22.                     Console.WriteLine("Access enabled");
  23.                     break;
  24.                 }
  25.                 else
  26.                 {
  27.                     Console.WriteLine("Wrong password. Try Again");
  28.                 }
  29.  
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment