syntax pengkonversian suhu dengan DEV C++ :
#include<iostream.h>
class suhu
{
public:
float celcius;
float reamur;
float kelvin;
float fahrenhait;
public:
void setCelcius(float celcius)
{
this->celcius=celcius;
}
float getCelcius()
{
return celcius;
}
void setReamur (float reamur)
{
this->reamur=reamur;
}
float getReamur()
{
return reamur;
}
void setKelvin(float kelvin)
{
this->kelvin=kelvin;
}
float getKelvin()
{
return kelvin;
}
void setFahrenhait (float fahrenhait)
{
this->fahrenhait=fahrenhait;
}
float getFahrenhait()
{
return fahrenhait;
}
float getR()
{
return 0.8*celcius;
}
float getF()
{
return 1.8*celcius+32;
}
float getK()
{
return celcius*273.15;
}
};
main()
{
float x;
suhu hasil;
cout<<" Suhu dalam celcius : ";
cin>>x;
hasil.setCelcius(x);
cout<<"CELCIUS KE REAMUR :"<<hasil.getR()<<endl;
cout<<"CELCIUS KE KELVIN :"<<hasil.getK()<<endl;
cout<<"CELCIUS KE FAHRENHAIT:"<<hasil.getF()<<endl;
system("pause");
}
Tidak ada komentar:
Posting Komentar