Write a program in c# sharp which will ask the user to create new username and password. Once finished creating, ask the user to log in using their log in details. the system will not terminate until such time the user enters both the username and password correctly
using System;
using System.Collections.Generic;
namespace App
{
class Program
{
public static void Main()
{
Console.Write("Enter new username: ");
string newUsername = Console.ReadLine();
Console.Write("Enter new password: ");
string newPassword = Console.ReadLine();
bool isCorrect = false;
while (!isCorrect) {
Console.Write("Enter the username: ");
string username = Console.ReadLine();
Console.Write("Enter the password: ");
string password = Console.ReadLine();
if (username == newUsername && password == newPassword)
{
Console.WriteLine("Correct.");
isCorrect = true;
}
}
Console.ReadLine();
}
}
}
Comments
Leave a comment