Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace While2_Password_Checker
- {
- class Program
- {
- static void Main(string[] args)
- {
- int loginattempts = 3;
- Console.Write("Enter Password: ");
- string a = "";
- string password = "kysurself";
- while (password != a)
- {
- a = Console.ReadLine();
- if ((password != a) && (loginattempts > 1))
- {
- loginattempts--;
- Console.WriteLine("Incorrect!");
- Console.WriteLine("Attempts left: " + loginattempts);
- Console.Write("Enter password: ");
- }
- else if (password == a)
- {
- Console.WriteLine("Welcome User!");
- }
- else if ((password != a) && (loginattempts == 1))
- {
- Console.WriteLine("Try again later!");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement