Home / Expert Answers / Computer Science / unlimited-tries-9-write-the-definition-of-class-named-temperature-the-temperature-class-will-ho-pa515

(Solved): Unlimited tries (9) Write the definition of class named Temperature. The Temperature class will ho ...



Unlimited tries
(9)
Write the definition of class named Temperature. The Temperature class will hold a temperature in Fahrenh

Unlimited tries (9) Write the definition of class named Temperature. The Temperature class will hold a temperature in Fahrenheit and provide methods to get the temperature in Fahrenheit, Celsius, and Kelvin. The class should have the following private field: - ftemp: a double that holds a Fahrenheit temperature. The class should have the following methods: - Constructor: The constructor should accept a Fahrenheit temperature (as a double) and assign it to the ftemp field. - setFahrenheit: This public method should accept a Fahrenheit temperature (as a double) and assign it to the ftemp field. - getFahrenheit: This public method should return the value of the ftemp field. The method should accept no arguments. - getcelsius: This public method should return the value of the ftemp field converted to Celsius. The method should accept no arguments. Use the following formula to convert to Celsius: Celsius \( =(5.0 / 9.0) *( \) Fahrenheit \( -32) \) - getKelvin: This public method should return the value of the ftemp field converted to Kelvin. The method should accept no arguments. Use the following formula to convert to Kelvin: Kelvin \( =(5.0 / 9.0) *( \) Fahrenheit - 32) \( )+273 \) Note: For this problem, write only the class definition for the Temperature class. Do not write a main method.


We have an Answer from Expert

View Expert Answer

Expert Answer


Answer : To implement the given class based program we will use the c++ class template and will declare various member functions in the class. The various member function in temperature class are : 1.
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe