15 Mart 2013 Cuma

27 - İf Else İf... Mevsimler...


Girilecek olan ayın sayısal numarasına göre hangi mevsimde olduğumuzu gösterecek olan bir program örneğidir... Örneğin 5 girilmesi durumunda, 5. ay Mayıs olduğu için İLKBAHAR mesajı ekranda gözükecektir... 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int ay = int.Parse(Console.ReadLine());
           
            if (ay <= 12 && ay >= 1)
            {
                if (ay>=3 && ay<=5)
                    Console.WriteLine("İLKBAHAR...");
                else if(ay>=6 && ay<=8)
                    Console.WriteLine("YAZ...");
                else if(ay<=9 && ay>=11)
                    Console.WriteLine("SONBAHAR...");
                else if (ay==12 || ay==1 || ay==2)
                    Console.WriteLine("KIŞ...");
            }
            else
                Console.WriteLine("HATA...");

            Console.ReadKey();

        }
    }
}