Hello,
It doesn't work because the scope of your variables is incorrect you need to put them above the do keyword, like this.
string username, pass;
do
{
Console.Write("Enter a username: ");
username =Console.ReadLine();
Console.Write("Enter a password: ");
pass = Console.ReadLine();
if (username =="john"&& pass=="mjamaa")
Console.WriteLine("Login Error");
}
while (username =="john"&& pass=="mjamaa");
Console.WriteLine("Login successful");
You have another logical mistake but I'll leave it to you.
Regards,
Eyal Shilony
No comments:
Post a Comment