Hi! I am having a problem with the following C++ program to build. \"Create a Te
ID: 3764001 • Letter: H
Question
Hi! I am having a problem with the following C++ program to build. "Create a Temperature class that internally stores a temperature, in degrees Kelvin. Create functions named setTempKelvin, setTempFarenheit, and set TempCelcius that an input in the specified scale, converts the temperature to Kelvin, and store the temperature in the class member variable. Also create functions that return and store temperature in Kelvin, Falrenheit, or Celsius. Write the main functions to test your class. Use Kelvin = Celsius+273.15 Celsius = (5.0/9) x (Farenheit-32.0)
Thank you in advance, Mike
Explanation / Answer
#include<iostream.h>
#include<conio.h>
class Temperature
{
public:
double kelvin, celsius, farenheit;
void setTempKelvin()
{
kelvin=celsius+273.15;
cout<<"Kelvin="<<kelvin<<endl;
}
void setTempCelsius()
{
celsius = (5.0/9)*(farenheit-32.0);
cout<<"Celsius="<<celsius<<endl;
}
void setTempFarenheit(double t)
{
farenheit=t;
cout<<"Farenheit="<<farenheit<<endl;
}
};
void main()
{
Temperature o;
double t;
cout<<"Enter Temperature";
cin>>t;
o.setTempFarenheit(t);
o.setTempCelsius();
o.setTempKelvin();
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.