IJUL'S BLOG

Konversi Suhu menggunakan C#

ni langsung aj ke source codenya gan:


namespace ConsoleApplication1
{
    class celc
    {
        public void Celcius()
        {
            Console.WriteLine("konversi Celcius");
            Console.WriteLine("====================");
            Console.Write("Inputkan Bilangan= ");
            double cel = double.Parse(Console.ReadLine());
            double fah = cel * 1.8 + 32;
            double rea = cel * 0.8;
         
            Console.WriteLine(cel + " Celcius = " + fah + " Fahrenheit");
            Console.WriteLine(cel + " Celcius = " + rea + " Reamur");
        }
    }
    class fahr
    {
        public void Fahrenheit()
        {
            Console.WriteLine("konversi Fahrenheit");
            Console.WriteLine("====================");
            Console.Write("Inputkan Bilangan= ");
            double fah = double.Parse(Console.ReadLine());
            double rea = (fah - 32) / 2.25;
            double cel = (fah - 32) / 1.8;
         
            Console.WriteLine(fah + " Fahrenheit = " + rea + " Reamur");
            Console.WriteLine(fah + " Fahrenheit = " + cel + " Celcius");
        }
    }
    class ream
    {
        public void Reamur()
        {
            Console.WriteLine("konversi Reamur");
            Console.WriteLine("====================");
            Console.Write("Inputkan Bilangan= ");
            double rea = double.Parse(Console.ReadLine());
            double fah = rea * 2.25 + 32;
            double cel = rea / 0.8;
         
            Console.WriteLine(rea+ " reamur = " + fah + " Fahrenheit");
            Console.WriteLine(rea + " reamur = " + cel + " Celcius");
        }
    }
    class program
    {
        static void Main(string[] args)
        {
            celc p1 = new celc();
            fahr p2 = new fahr();
            ream p3 = new ream();
         
            Console.WriteLine("1.Konversi Dari Celcius");
            Console.WriteLine("2.Konversi Dari Fahrenheit");
            Console.WriteLine("3.Konversi Dari Reamur");
            ulang:
            Console.Write("Inputkan Pilihan= ");
            int pilih = int.Parse(Console.ReadLine());
            if (pilih <= 3)
                switch (pilih)
                {
                    case 1:
                        {
                            p1.Celcius();
                            break;
                        }
                    case 2:
                        {
                            p2.Fahrenheit();
                            break;
                        }
                    case 3:
                        {
                            p3.Reamur();
                            break;
                        }
                 
                }
            else
            {
                Console.WriteLine("Pilihan Salah,Pilihan Hanya Dari 1-3");
                goto ulang;
            }


            Console.ReadLine();
        }
    }
}

1 komentar:

Unknown mengatakan...

makasih gan

Posting Komentar

Powered By Blogger
Diberdayakan oleh Blogger.

Entri Populer

PENGUNJUNG

Buku Tamu

About Me

Foto Saya
Ijal Ferdi
there is no something special about me,,, but this blog is so special for me......
View my complete profile

Total Tayangan Halaman

Followers