Sabtu, 22 Maret 2014
Konversi 4 Suhu
Dalam C++
float suhu, hasila, hasilb, hasilc;
int kode;
char pilihan;
cout << " Konversi Suhu" <<endl<<endl;
cout << " 1. Celcius Ke> Reamur " << endl;
cout << " Celcius Ke> Fahrenheit " << endl;
cout << " Celcius Ke> Kelvin " << endl;
cout << " 2. Reamur Ke> Celcius " << endl;
cout << " Reamur Ke> Fahrenheit " << endl;
cout << " Reamur Ke> Kelfin " << endl;
cout << " 3. Fahrenheit Ke> Celcius " << endl;
cout << " Fahrenheit Ke> Reamur " << endl;
cout << " Fahrenheit Ke> Kelvin " << endl;
cout << " 4. Kelvin Ke> Celcius " << endl;
cout << " Kelvin Ke> Fahrenheit " << endl;
cout << " Kelvin Ke> Reamur " << endl;
cout << endl<<endl;
cout << "Masukkan Kode Diatas = ";
cin >> kode;
cout << endl;
switch(kode)
{
case 1:
cout << "Masukkan Suhu Dalam Celcius = ";
cin >> suhu ;
hasila = 0.8*suhu ;
cout <<endl;
cout << "Suhu Dalam Reamur = " << hasila << endl;
hasilb = suhu*1.8+32;
cout << "Suhu Dalam Fahrenheit = " << hasilb << endl;
hasilc = suhu+273.15;
cout << "Suhu Dalam Kelvin = " << hasilc << endl;
cout<<endl;
break;
case 2:
cout << "Masukkan Suhu Dalam Reamur = ";
cin >> suhu ;
hasila = suhu/0.8;
cout <<endl;
cout << "Suhu Dalam Celcius = " << hasila << endl;
hasilb = suhu*2.25+32;
cout << "Suhu Dalam Fahrenheit = " << hasilb << endl;
hasilc = suhu/0.8+273.15;
cout << "Suhu Dalam Kelvin = " << hasilc << endl;
cout<<endl;
break;
case 3:
cout << "Masukkan Suhu Dalam Fahrenheit = ";
cin >> suhu ;
hasila = (suhu-32)/1.8;
cout <<endl;
cout << "Suhu Dalam Celcius = " << hasila << endl;
hasilb = (suhu-32)/2.25;
cout << "Suhu Dalam Reamur = " << hasilb << endl;
hasilc = (suhu+459.67)/1.8;
cout << "Suhu Dalam Kelvin = " << hasilc << endl;
cout<<endl;
break;
case 4:
cout << "Masukkan Suhu Dalam Kelvin = ";
cin >> suhu ;
hasila = suhu-273.15;
cout <<endl;
cout << "Suhu Dalam Celcius = " << hasila << endl;
hasilb = suhu*1.8-459.67;
cout << "Suhu Dalam Fahrenheit = " << hasilb << endl;
hasilc = (suhu-273.15)*0.8;
cout << "Suhu Dalam Reamur = " << hasilc << endl;
cout<<endl;
break;
default:
cout << "Kode angka salah" << endl<<endl;
}
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar