[Solved] Using Two Classes Create Program Convert Fahrenheit Temperature Celsius Kelvin Temperature Q37178264


Using two classes, create a program that can convert a Fahrenheit temperature to Celsius and Kelvin. Temperature Class (Temperature.java) Should have one private field, a double, named fTemp. . Should have a no-arg constructor that simply initializes fTemp to 1. . Should have a public mutator method named setTemperature that accepts a double as an argument. Name the parameter fTempln. This method should overwrite fTemp with the value of the argument passed in to the method o Should have a public accessor method named getTemperature that returns the value of fTemp. Should have a public accessor method named toCelsius that returns the temperature (value of fTemp) in Celsius. . F to C conversion: (fTemp- 32) * (5/9) Should have a public accessor method named toKelvin that returns the temperature (value of fTemp) in Kelvin. F to K conversion: (fTemp + 459.67) (5/9) .Neither the toCelsius or tokelvin method should overwrite or alter the value of the fTemp field. TemperatureDemo Class (TemperatureDemo.java) This is the class that will demo the Temperature class you created; thus, it contains the main method. In the main method: Instantiate a new instance of the Temperature class. Prompt the user to enter a temperature in Fahrenheit. Using the value the user entered, set your Temperature object’s fTemp field using its setTemperature method. Using the Temperature object’s getTemperature, toCelsius, and tokelvin methods, print: o The temperature in Fahrenheit o The temperature in Celsius. o The temperature in Kelvin o All output should be rounded to 2 decimal places Be sure to use comments to document your code. We were unable to transcribe this imageShow transcribed image text Using two classes, create a program that can convert a Fahrenheit temperature to Celsius and Kelvin. Temperature Class (Temperature.java) Should have one private field, a double, named fTemp. . Should have a no-arg constructor that simply initializes fTemp to 1. . Should have a public mutator method named setTemperature that accepts a double as an argument. Name the parameter fTempln. This method should overwrite fTemp with the value of the argument passed in to the method o Should have a public accessor method named getTemperature that returns the value of fTemp. Should have a public accessor method named toCelsius that returns the temperature (value of fTemp) in Celsius. . F to C conversion: (fTemp- 32) * (5/9) Should have a public accessor method named toKelvin that returns the temperature (value of fTemp) in Kelvin. F to K conversion: (fTemp + 459.67) (5/9) .Neither the toCelsius or tokelvin method should overwrite or alter the value of the fTemp field. TemperatureDemo Class (TemperatureDemo.java) This is the class that will demo the Temperature class you created; thus, it contains the main method. In the main method: Instantiate a new instance of the Temperature class. Prompt the user to enter a temperature in Fahrenheit. Using the value the user entered, set your Temperature object’s fTemp field using its setTemperature method. Using the Temperature object’s getTemperature, toCelsius, and tokelvin methods, print: o The temperature in Fahrenheit o The temperature in Celsius. o The temperature in Kelvin o All output should be rounded to 2 decimal places Be sure to use comments to document your code.
Expert Answer
Answer to Using two classes, create a program that can convert a Fahrenheit temperature to Celsius and Kelvin. Temperature Class (… . . .
Related