private static Random random = new Random();
public static void Main(String[] args)
String[] userNameArray = new String[5];
int[] passwordArray = new int[5];
for (x = 0 ; x <= 4 ; x += 1)
a = random.Next(25) + 65;
b = random.Next(25) + 65;
c = random.Next(25) + 65;
userNameArray[x] = (char) (a) + (char) (b) + (char) (c);
passwordArray[x] = a * 100 + b * 10 + c * 1;
Console.WriteLine("user, Pwd");
for (x = 0 ; x <= 4 ; x += 1)
Console.WriteLine(userNameArray[x] + ", " + passwordArray[x]);
while (failedAttempts < 3 && found == false)
Console.WriteLine("Please enter your user name: ");
Console.WriteLine("Please enter your password: ");
while (x < userNameArray.Length && found == false)
if (userName == userNameArray[x] && password == passwordArray[x])
failedAttempts = failedAttempts + 1;
Console.WriteLine("You entered the wrong username and or password. Try again. After three failed login attempts you will be locked out.");
Console.WriteLine("Welcome to the system...");
Console.WriteLine("Access denied. Third login attempt unsuccessfull. Your automatically locked out forever.");
private static void input(out double result)
while (!double.TryParse(Console.ReadLine(), out result));
private static void input(out int result)
while (!int.TryParse(Console.ReadLine(), out result));
private static void input(out Boolean result)
while (!Boolean.TryParse(Console.ReadLine(), out result));
private static void input(out string result)
result = Console.ReadLine();