Question: Write a Temperature class that will hold a temperature in Fahrenheit, and provide methods to get the temperature in Fahrenheit, Celsius, and Kelvin. The class

Write a Temperature class that will hold a temperature in Fahrenheit, and provide methods to get the temperature in Fahrenheit, Celsius, and Kelvin. The class should have the following field: fahrenheit - A double that holds a Fahrenheit temperature. The class should have the following methods: Constructor - The constructor accepts a Fahrenheit temperature (as a double) and stores it in the ftemp field. setFahrenheit - The setFahrenheit method accepts a Fahrenheit temperature (as a double) and stores it in the ftemp field. getFahrenheit - Returns the value of the ftemp field, as a Fahrenheit temperature (no conversion required). celsius - Returns the value of the ftemp field converted to Celsius. kelvin - Returns the value of the ftemp field converted to Kelvin

Use the following formula to convert the Fahrenheit temperature to Celsius: Celsius=(5/9) *(Fahrenheit-32) Use the following formula to convert the Fahrenheit temperature to Kelvin: Kelvin=((5/9) *(Fahrenheit-32))+273 Demonstrate the Temperature class by writing a separate program that asks the user for a Fahrenheit temperature. The program should create an instance of the Temperature class, with the value entered by the user passed to the constructor. The program should then call the object's methods to display the temperature in Celsius and Kelvin.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the implementation of the Temperature class in Python class Temperature def initself fa... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!