(Please give all the solutions and steps, if you give the answer by picture plea
ID: 3914670 • Letter: #
Question
(Please give all the solutions and steps, if you give the answer by picture please post a clear picture. Please don't answer the question if you can't do all the questions, THANKS).
2. (50 points) Create a Temperature class that internally stores a temperature in degrees Kelvin. Create functions named setTempKelvin, setTempFahrenheit, and setTempCelsius that take an input temperature in the specified temperature scale, and convert the tem- perature to Kelvin, and store that temperature in the class member private variable Also, create functions that return the stored temperature in degrees Kelvin, Fahrenheit, or Celsius. The conversions are as follows: Kelvin = Celsius 273.15 Celsius = (5.0/9) + (Fahrenheit -32) Use appropriate types for each value/scale. Use a similar approach to Question 1. You may use it as your skeleton code for this solutionExplanation / Answer
/* Create a Temperature class that returns a conversion to a user selected scale Kelvin = Celsius + 273.15 Celsius = (5.0/9) * (Fahrenheit - 32) */ #include class Temperature { public: //default constructor Temperature() : kelvin(NULL), fahrenheit(NULL), celsius(NULL) {/*body intentionally left blank*/} //constructor: Kelvin, Fahrenheit, Celsius Temperature(double kel, double fahr, double cel) : kelvin(kel), fahrenheit(fahr), celsius(cel) {/*body intentionally left blank*/} double kelToCel(double); double kelToFahr(double); double celToKel(double); double celToFahr(double); double fahrToCel(double); double fahrToKel(double); private: double kelvin = 0; double fahrenheit = 0; double celsius = 0; }; double Temperature::kelToCel(double kel) { kelvin = kel; return celsius = kel - 273.15; } double Temperature::kelToFahr(double kel) { kelvin = kel; return fahrenheit = (9.0 / 5) * (kel - 273.15) + 32; } double Temperature::celToKel(double cel) { celsius = cel; return kelvin = cel + 273.15; } double Temperature::celToFahr(double cel) { celsius = cel; return fahrenheit = cel * (9.0 / 5) + 32; } double Temperature::fahrToCel(double fahr) { fahrenheit = fahr; return celsius = (5.0 / 9) * (fahr - 32); } double Temperature::fahrToKel(double fahr) { fahrenheit = fahr; return kelvin = (5.0 / 9) * (fahr - 32) + 273.15; } int main() { std::coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.