Question #280072

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


Expert's answer

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();
        }
    }
}
LATEST TUTORIALS
APPROVED BY CLIENTS