Translate

20 Nov 2013

Program Konversi Suhu

Dibawah adalah Program Konversi Suhu - c++ -> g++ pada linux menggunakan geany. 
Jadi sebelum mencoba sintax dibawah install terlebih dahulu geany nya.
Kurang lebih output program nya bak dibawah.



dan sintax nya sbb:


#include <iostream>
#include <string>
using namespace std;

int main()
{
float cl, re, kl, fh;
int menu;
cout<<" PROGRAM KONVERSI SUHU \n";
cout<<"************************\n";
cout<<"suhu-suhu\n";
cout<<"1.celcius\n";
cout<<"2.kelvin\n";
cout<<"3.reamur\n";
cout<<"4.fahrenheit\n";

cout<<"Pilih Suhu (1-4) = ";cin>>menu;
switch(menu)
{
case 1:
cout<<"masukan nilai = ";cin>>cl;
kl=cl+273.15;
cout<<"kelvin = "<<kl<<endl;
re=cl*0.8;
cout<<"reamur = "<<re<<endl;
fh=(cl*1.8)+32;
cout<<"fahrenheit = "<<fh<<endl;
break;
case 2:
cout<<"masukan nilai = ";cin>>kl;
cl=kl-273.15;
cout<<"celcius = "<<cl<<endl;
re=(kl-273.15)*0.8;
cout<<"reamur = "<<re<<endl;
fh=kl*1.8-459.67;
cout<<"fahrenheit = ";
break;
case 3:
cout<<"masukan nilai = ";cin>>re;
cl=re/0.8;
cout<<"celcius = "<<cl<<endl;
kl=re/0.8+273.15;
cout<<"Kelvin = "<<kl<<endl;
fh=re*2.25+32;
cout<<"fahrenheit = "<<fh<<endl;
break;
case 4:
cout<<"masukan = ";cin>>fh;
cl=(fh-32)/1.8;
cout<<"celcius = "<<fh<<endl;
kl=(fh-32)/1.8+273.15;
cout<<"kelvin = "<<kl<<endl;
re=(fh-32)/2.25;
cout<<"reamur = "<<re<<endl;
break;
}

}

Terima kasih semoga bermanfaat
Comments
0 Comments