70٪ تخفیف ویژه جشنواره تابستانه توسینسو
پایان تخفیف تا:
مشاهده دوره‌ها
0

برنامه نویسی

برنامه ای بنویسید که نام کاربری و رمز عبور را از کاربر دریافت نماید و در صورت صحیح بودن، سه عدد از ورودی بگیرد لطفا حلش کنید ممنون
پرسیده شده در 1402/02/15 توسط

1 پاسخ

0

using System;

class Program

{

    static void Main(string[] args)

    {

        // Define correct username and password

        string correctUsername = "username";

        string correctPassword = "password";

        // Prompt user for username

        Console.Write("Enter username: ");

        string username = Console.ReadLine();

        // Prompt user for password

        Console.Write("Enter password: ");

        string password = Console.ReadLine();

        // Check if username and password are correct

        if (username == correctUsername && password == correctPassword)

        {

            Console.WriteLine("Login successful!");

            // Prompt user for three numbers

            Console.Write("Enter number 1: ");

            int num1 = int.Parse(Console.ReadLine());

            Console.Write("Enter number 2: ");

            int num2 = int.Parse(Console.ReadLine());

            Console.Write("Enter number 3: ");

            int num3 = int.Parse(Console.ReadLine());

            // Print sum of three numbers

            int sum = num1 + num2 + num3;

            Console.WriteLine("Sum of three numbers: " + sum);

        }

        else

        {

            Console.WriteLine("Invalid username or password.");

        }

        // Wait for user input before closing console window

        Console.ReadLine();

    }

}

پاسخ در 1402/02/15 توسط

پاسخ شما