Konversi Suhu menggunakan C#
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();
}
}
}
Sabtu, November 12, 2011
|
Label:
C#
|
Langganan:
Posting Komentar (Atom)
Diberdayakan oleh Blogger.
Entri Populer
-
source code ini simple bgt deh,,,hhe.....,,mklum baru bljr.... namespace ConsoleApplication1 { class Program { static...
-
source codenya pasti mantap dah,,,ckckck... namespace ConsoleApplication1 { class Program { static void Main(string[]...
-
source code program persegi bintang pada c++; #include <iostream.h> #include <conio.h> int main() { int ukuran; do ...
Buku Tamu
Arsip Blog
About Me

- Ijal Ferdi
- there is no something special about me,,, but this blog is so special for me......
1 komentar:
makasih gan
Posting Komentar