private static Random random = new Random();
public static void Main(string[] args)
string[] usernames = new string[5];
int[] passwords = new int[5];
for (index = 0; index <= 4; index++)
usernames[index] = Convert.ToString((char)(random.Next(25) + 65)) + (char)(random.Next(25) + 65) + (char)(random.Next(25) + 65);
for (index = 0; index <= 4; index++)
passwords[index] = random.Next(899) + 100;
output("Username, Password" + "\n");
for (index = 0; index <= 4; index++)
output(usernames[index] + ", " + passwords[index] + "\n");
output("Enter a username:" + "\n");
output("Enter a password:" + "\n");
pass = (int) inputValue();
while (index < usernames.Length && access == false)
if (usernames[index] == user && passwords[index] == pass)
while (access == false && attempts < 2)
output("Invalid Username and Password. Please Try Again." + "\n");
output("Enter a username:" + "\n");
output("Enter a password:" + "\n");
pass = (int) inputValue();
while (index < usernames.Length && access == false)
if (usernames[index] == user && passwords[index] == pass)
output("Welcome to the System." + "\n");
output("Sorry. Access Denied." + "\n");
private static double inputValue()
while (!double.TryParse(Console.ReadLine(), out result));
private static string inputText()
return Console.ReadLine();
private static void output(string text)