English

Implement a Class Temperature. Include a Constructor in It Which Accepts Value of Temperature from User .In Degree Celsius. Include Two Functions In It, One of Which Calculates Its Equivalent Temperature in Degree Fahrenheit And Other Function Prints the Answer.

Advertisements

Question

Implement a class temperature. Include a constructor in it which accepts value of temperature from user .in degree Celsius. Include two functions in it, one of which calculates its equivalent temperature in degree Fahrenheit and other function prints the answer.

Advertisements

Solution

#include
class temperature
{
  float cel;
  float far;
  public : Temperature(); //constructor
  void convert();
  void print();
};
temperature::temperature()
{
  cout<<"Enter the degree celsius";
  cin>>cel;
}
void temperature::convert()
{
  far = cel * 9/5 + 32;
}
void temperature::print()
{
  cout<<"The degree fahernheit is:";
  cout<<far;
}
void main()
{
  temperaute obj;
  obj.convert();
  obj.print();
}
shaalaa.com
  Is there an error in this question or solution?
2015-2016 (March)

APPEARS IN

Advertisements
Share
Notifications



      Forgot password?
Use app×