Page 1 of 1

Write a C# Sharp program that takes user id and password as input (type string). After 3 wrong attempts, user will be re

Posted: Fri May 20, 2022 11:43 am
by answerhappygod
Write a C# Sharp program that takes user id and password as
input (type string). After 3 wrong attempts, user will be rejected.
C# Sharp Code: using System; public class Exercise3 { public static
void Main() { string username, password; int ctr = 0,dd=0;
Console.Write("\n\nCheck username and password :\n");
Console.Write("N.B. : Defaule username and password is : username
and password\n");
Console.Write("---------------------------------\n"); do {
Console.Write("Input a username: "); username = Console.ReadLine();
Console.Write("Input a password: "); password = Console.ReadLine();
if( username == "username" && password == "password" ) {
dd=1; ctr=3; } else { dd=0; ctr++; } } while (( username !=
"username" || password != "password" ) && (ctr != 3)); if
(dd == 0) { Console.Write("\nLogin attemp more than three times.
Try later!\n\n"); } 6 | P a g e Loops in C# Hands-on Ms. Rosita
Glover IST51/IST551 else if(dd==1) { Console.Write(