0% found this document useful (0 votes)
45 views

C# Codes

This C# program prompts the user to enter a username and password. It checks the input against predefined credentials and allows up to 3 failed attempts before locking the user out. On the 4th failed attempt, it displays a message telling the user to try logging in later. If the correct credentials are entered before the 4th attempt, it displays a success message.

Uploaded by

Jay-ar Ylagan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

C# Codes

This C# program prompts the user to enter a username and password. It checks the input against predefined credentials and allows up to 3 failed attempts before locking the user out. On the 4th failed attempt, it displays a message telling the user to try logging in later. If the correct credentials are entered before the 4th attempt, it displays a success message.

Uploaded by

Jay-ar Ylagan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System;

public class FinalDiscussion


{
public static void Main()
{
string username, password;
int ctr = 0;
do
{
Console.Write("Input a username: ");
username = Console.ReadLine();

Console.Write("Input a password: ");


password = Console.ReadLine();

if (username != "abcd" || password != "1234")


ctr++;
else
ctr = 1;

}
while ((username != "admin" || password != "123456") && (ctr != 4));

if (ctr == 4)
Console.WriteLine("\nLogin attemp three or more times. Try later!");
else
Console.WriteLine("\nThe username and password entered successfully!");

Console.ReadLine();
Console.ReadKey();
}
}

You might also like