private static Random random = new Random();
public static void Main(String[] args)
String[] usernameArray = new String[5];
int[] passwordArray = new int[5];
Console.WriteLine("Username & Password");
for (index = 0 ; index <= 4 ; index += 1)
usernameArray[index] = ((char) (random.Next(26) + 65)).ToString() + (char) (random.Next(26) + 65) + (char) (random.Next(26) + 65);
passwordArray[index] = random.Next(899) + 100;
Console.WriteLine(" " + usernameArray[index] + " & " + passwordArray[index]);
while (accessGranted != true && accessAttempts < 3)
Console.WriteLine("Please enter your username: ");
Console.WriteLine("Please enter your password: ");
while (index < 5 && accessGranted == false)
if (usernameArray[index] == username && passwordArray[index] == password)
if (accessGranted != true)
Console.WriteLine("Invalid username and/or password. Please try again.");
accessAttempts = accessAttempts + 1;
if (accessGranted == true)
Console.WriteLine("Welcome to the system");
Console.WriteLine("Sorry. Access Denied.");
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();