Exercise
Password 5 attempts
Objetive
Write a C# program that prompts the user for their username and password. Both should be strings. After 5 incorrect attempts, the user will be rejected.
Example Code
using System;
public class Exercise52
{
public static void Main()
{
string user, pass;
int count = 0;
do
{
Console.Write("Enter username: ");
user = Console.ReadLine();
Console.Write("Enter password: ");
pass = Console.ReadLine();
count++;
}
while (((user != "user") || (pass != "password"))
&& (count != 5));
if (count == 5)
Console.Write("Login attemp fail!");
else
Console.Write("Password correct!");
}
}