Write c++ program to create a class temperature which converts temperature fahrenheit to celcious
//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;
#include<iostream.h>
#include<conio.h>
class temperature
{
float a; // a= temperature in fahrenheit
float b; // b= Temerature in celcious
public:
void read()
{
cout<<"Enter the temperature in fahrenheit: "<<endl;
cin>>a;
}
void convert()
{
b=(a-32)*5/9;
cout<<"Temerature in celcious is: "<<b<<endl;
}
};
int main()
{
cin>>a;
cout<<"The value in celcius: "<<(a-32)*5/9<<" C"; */
temperature obj; //object created
obj.read();
obj.convert();
getch();
return(0);
}
0 Comments