Ask Question
13 August, 05:03

Temperature 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: ftemp. 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). getCelsius. Returns the value of the ftemp field converted to Celsius. getKelvin. Returns the value of the ftemp field converted to Kelvin.

+4
Answers (1)
  1. 13 August, 08:03
    0
    public class Temperature

    {

    double ftemp;

    public int Constructor (double fahrenheit)

    {

    ftemp = fahrenheit;

    return Convert. ToInt32 (ftemp);

    }

    public void setFahrenheit (double fahrenheit)

    {

    ftemp = fahrenheit;

    }

    public void getFahrenheit ()

    {

    ftemp = Constructor (ftemp);

    }

    public void getCelcius ()

    {

    ftemp = (ftemp - 32) * 5 / 9;

    }

    public void getKelvin ()

    {

    ftemp = (ftemp - 32) * 5 / 9 + 273.15;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Temperature Class Write a Temperature class that will hold a temperature in Fahrenheit and provide methods to get the temperature in ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers