Class Celcius c++


suhu memang cepat sekali berubah, kadang panas kadang dingin.. kadang juga gak panas juga gak dingin, terus apa donk?? hangat…
sekarang kita akan mencoba membuat program untuk menentukan suhu.
go to program..

#include
#include
class Celcius {
friend ostream& operator<>(istream&,Celcius&);
public:
Celcius(double a=0):c(a){}
double reamur() const;
double fahrenheit() const;
double kelvin() const;
private:
double c;
};
ostream& operator<<(ostream& out,const Celcius& j){
out << "Reamur : " << j.reamur();
out << "\nFahrenheit : " << j.fahrenheit();
out << "\nKelvin : " <>(istream& in,Celcius& j){
cout <> j.c;
return in;
}
double Celcius::reamur()const{
return (4/5.0*c);
}
double Celcius::fahrenheit()const{
return (9/5.0*c+32);
}
double Celcius::kelvin()const{
return (c+273);
}
void main(){
Celcius j;
cin >> j;
cout << j;
getch();
}

ternyata membuat program seperti ini tidak mudah..
semoga bermanfaat

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: