본문 바로가기
언어/[C#]

[C#] if 조건문 if - else if - else

by 조랩 2023. 3. 1.
using System;

namespace MyFirstProgram
{
    internal class Program
    {

        static void Main(string[] args) // main method
        {
        
            // if 조건문

            Console.WriteLine("Please enter your age: ");
            int myAge = Convert.ToInt32(Console.ReadLine());

            if (myAge > 100)
            {
            	Console.WriteLine("You are too old to sign up!");
            }
            else if (myAge < 0)
            {
                Console.WriteLine("You haven't been born yet!");
            }
            else if (myAge >= 18)
            {
                Console.WriteLine("You are now signed up");
            }
            else
            {
                Console.WriteLine("You must be 18+ to sign up!");
            }

        }
    }
}
728x90