Advertisement
420merri

Password Checker

Dec 16th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace While2_Password_Checker
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int loginattempts = 3;
  10.             Console.Write("Enter Password: ");
  11.             string a = "";
  12.             string password = "kysurself";
  13.             while (password != a)
  14.             {
  15.                 a = Console.ReadLine();
  16.                 if ((password != a) && (loginattempts > 1))
  17.                 {
  18.                     loginattempts--;
  19.                     Console.WriteLine("Incorrect!");
  20.                     Console.WriteLine("Attempts left: " + loginattempts);
  21.                     Console.Write("Enter password: ");
  22.  
  23.                 }
  24.                 else if (password == a)
  25.                 {
  26.                     Console.WriteLine("Welcome User!");
  27.                 }
  28.                 else if ((password != a) && (loginattempts == 1))
  29.                 {
  30.                     Console.WriteLine("Try again later!");
  31.                     break;
  32.                 }
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement