20. Sorunun Cevabı

20. Girilen işlem türüne (* / - +) göre iki sayıyı işleme alıp sonucunu ekrana yazan programı yapınız. (Tüm soruları görmek için tıklayınız.)

 
//20. Girilen işlem türüne (* / - +) göre iki sayıyı işleme alıp sonucunu ekrana yazan programı yapınız. http://2gx.org
#region Kütüphane Dosyaları
using System;
using System.Collections.Generic;
using System.Text;
#endregion
 
namespace hesap_makinesi_2gx
{
    class Program
    {
        #region Bekleme Modu
        static void Bekle()
        {
            while (true)
            {
                // ...Loading
            }
        }
        #endregion
 
        #region Klavye girişleri
        static double TusAl()
        {
            return double.Parse(Console.ReadLine());
        }
        #endregion
 
        #region HESAP32 Anaekranı
        static  void AnaEkran()
        {
            Console.Clear();
            Console.WriteLine("---------------Hesap Makinesi 2gx---------------");
            Console.WriteLine("[1] TOPLAMA");
            Console.WriteLine("[2] CIKARMA");
            Console.WriteLine("[3] CARPMA");
            Console.WriteLine("[4] BOLME");
            Console.WriteLine("[5] KAREAL");
            Console.WriteLine("[CTRL+C] CIKIS");
 
            switch (Convert.ToInt32(TusAl()))
            {
                case 1: Toplama(); break;
                case 2: Cikarma(); break;
                case 3: Carpma();  break;
                case 4: Bolme(); break;
                case 5: KareAl(); break;
                default: AnaEkran(); break;
            }
        }
        #endregion
 
        #region HESAP32 İşlemler Bloğu
        static void Toplama()
        {
            try
            {
                Console.WriteLine("-----TOPLAMA ISLEMI-----");
                Console.WriteLine("1.Sayiyi gir= ");
                double s1 = double.Parse(Console.ReadLine());
                Console.WriteLine("2.Sayiyi gir= ");
                double s2 = double.Parse(Console.ReadLine());
 
                double sonuc = s1 + s2;
                Console.WriteLine("Sonuc= " + sonuc.ToString());
                Console.WriteLine("Ana Ekrana Donmek icin [ENTER]");
                Console.ReadLine();
                AnaEkran();
            }
            catch
            {
                Hata();
            }
        }
 
        static void Cikarma()
        {
            try
            {
                Console.WriteLine("-----CIKARMA ISLEMI-----");
                Console.WriteLine("1.Sayiyi gir= ");
                double s1 = double.Parse(Console.ReadLine());
                Console.WriteLine("2.Sayiyi gir= ");
                double s2 = double.Parse(Console.ReadLine());
 
                double sonuc = s1 - s2;
                Console.WriteLine("Sonuc= " + sonuc.ToString());
                Console.WriteLine("Ana Ekrana Donmek icin [ENTER]");
                Console.ReadLine();
                AnaEkran();
            }
            catch
            {
                Hata();
            }
        }
 
        static void Carpma()
        {
            try
            {
                Console.WriteLine("-----CARPMA ISLEMI-----");
                Console.WriteLine("1.Sayiyi gir= ");
                double s1 = double.Parse(Console.ReadLine());
                Console.WriteLine("2.Sayiyi gir= ");
                double s2 = double.Parse(Console.ReadLine());
 
                double sonuc = s1 * s2;
                Console.WriteLine("Sonuc= " + sonuc.ToString());
                Console.WriteLine("Ana Ekrana Donmek icin [ENTER]");
                Console.ReadLine();
                AnaEkran();
            }
            catch
            {
                Hata();
            }
        }
 
        static void Bolme()
        {
            try
            {
                Console.WriteLine("-----BOLME ISLEMI-----");
                Console.WriteLine("1.Sayiyi gir= ");
                double s1 = double.Parse(Console.ReadLine());
                Console.WriteLine("2.Sayiyi gir= ");
                double s2 = double.Parse(Console.ReadLine());
 
                double sonuc = s1 / s2;
                Console.WriteLine("Sonuc= " + sonuc.ToString());
                Console.WriteLine("Ana Ekrana Donmek icin [ENTER]");
                Console.ReadLine();
                AnaEkran();
            }
            catch
            {
                Hata();
            }
        }
 
        static void KareAl()
        {
            try
            {
                Console.WriteLine("-----KARE AL-----");
                Console.WriteLine("Karesi alinacak sayi gir= ");
                double s1 = double.Parse(Console.ReadLine());
                double sonuc = s1 * s1;
                Console.WriteLine("Sonuc= " + sonuc.ToString());
                Console.WriteLine("Ana Ekrana Donmek icin [ENTER]");
                Console.ReadLine();
                AnaEkran();
            }
            catch
            {
                Hata();
            }
        }
 
       #endregion
 
        #region HESAP32 Hata önleme kodu
        static void Hata()
        {
            Console.Clear();
            Console.WriteLine("COK BUYUK BIR SAYI YADA HARF GIRDINIZ");
            Console.WriteLine("PROGRAMIN DUZGUN CALISMASI ICIN DAHA DIKKATLI OLUN");
            Console.WriteLine("ANA EKRANA DONMEK ICIN BIR TUSA BASIN");
            Console.ReadLine();
            AnaEkran();
        }
        #endregion
 
        #region HESAP32 Anametod
        static void Main(string[] args)
        {
            //:Kodlar buraya
            Console.Title = "HESAP MAKİNESİ --2gx.org-- c# Console Deneme";
            AnaEkran();
            Bekle();
        }
        #endregion
    }
}

May 21st, 2010 | Kategoriler Ders, Yazılım | Toplam Okunma=208
İlk yorumu siz yazın.

Yorum Yazın

XHTML: İzin verilen HTML kodları: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Switch to our mobile site