Hey everyone, This is a question I am sort of having trouble with. Theprogram sh
ID: 3616416 • Letter: H
Question
Hey everyone,This is a question I am sort of having trouble with. Theprogram should have a temperature class which stores temperature indegrees kelvin. Then create functions such as setKelvin, setCelsiusand setFarenheit. It pretty much uses formula
Kelvin = Celsius + 273.15
Celsius = (5/9) X (Fahrenheit - 32)
I have done something but it prints out right for 0. I am not evensure if I did anything is right. I am posting my work down, pleasehelp me out! If anyone wants the exact question, that is alsoposted below.
Create a Temperature class that internally stores a temperature indegrees
Kelvin. However, create functions named setTempKelvin,setTempFahrenheit, and
setTempCelsius that takes an input temperature in the specifiedtemperature scale,
converts the temperature to Kelvin, and stores that temperature inthe class
member variable. Also create functions that return the storedtemperature in
degrees Kelvin, Fahrenheit, or Celsius. Write a main functionto test your class.
Use the equations below to convert between the three temperaturescales.
#include <iostream>
#include <cstdlib>
using namespace std;
class Temperature{
public:
void setTempCelsius();
void setTempKelvin();
void setTempFarenheit();
double getTempKelvin(doublec);
double getTempCelsius(doublef);
double getTempFarenheit(doublec);
private:
double kelvin,celsius,farenheit;
};
int main(){
Temperature temp;
cout<<"Celsius:"<<temp.getTempCelsius(100.0)<<endl;
cout<<"Farenheit:"<<temp.getTempFarenheit(100.0)<<endl;
cout<<"Kelvin:"<<temp.getTempKelvin(100.0)<<endl;
system("pause");
return 0;
}
void Temperature::setTempKelvin(){
}
void Temperature::setTempCelsius(){
}
void Temperature::setTempFarenheit(){
}
double Temperature::getTempKelvin(double c){
return c+273.15;
}
double Temperature::getTempCelsius(double f){
return (5/9)*(f-32);
}
double Temperature::getTempFarenheit(double c){
return ((9/5)*c)+32;
}