Program ini dibuat menggunakan class untuk mencari celcius, se,oga bermanfaat bagi teman-teman. . . ^_^
#include <iostream.h>
#include <conio.h>
class Celcius {
friend ostream& operator<<(ostream&,const Celcius&);
friend istream& 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 : " << j.kelvin();
return out;
}
istream& operator>>(istream& in,Celcius& j){
cout << "Masukkan suhu dalam Celcius : "; in >> 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();
Tidak ada komentar:
Posting Komentar