You are on page 1of 2

/* * Created by SharpDevelop.

* User: hp * Date: 20/2/2013 * Time: 10:50 AM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; namespace konversi_suhu { class celc { public void Celcius() { Console.WriteLine("Konversi Dari Celcius ke Fahrenheit"); Console.WriteLine("===================="); Console.Write("Inputkan Bilangan= "); double cel = double.Parse(Console.ReadLine()); double fah = cel * 1.8 + 32; Console.WriteLine(cel + " Celcius = " + fah + " Fahrenheit"); } } class fahr { public void Fahrenheit() { Console.WriteLine("Konversi Dari Fahrenheit ke Celcius"); Console.WriteLine("===================="); Console.Write("Inputkan Bilangan= "); double fah = double.Parse(Console.ReadLine()); double cel = (fah - 32) / 1.8; Console.WriteLine(fah + " Fahrenheit = " + cel + " Celcius"); } } class program { static void Main(string[] args) { celc p1 = new celc(); fahr p2 = new fahr(); Console.WriteLine("1.Konversi Dari Celcius ke Fahrenheit"); Console.WriteLine("2.Konversi Dari Fahrenheit ke Celcius"); ulang: Console.Write("Inputkan Pilihan= "); int pilih = int.Parse(Console.ReadLine()); if (pilih <= 2) switch (pilih) { case 1: { p1.Celcius(); break; } case 2: {

p2.Fahrenheit(); break; } } else { Console.WriteLine("Pilihan Salah,Pilihan Hanya Dari 1-2"); goto ulang; } Console.ReadLine(); } } }

You might also like