210k views
2 votes
Write a Temperature class that will hold a temperature in Fahrenheit and provide methodsto get the temperature in Fahrenheit, Celsius, and Kelvin. The class should have the followingfield: 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 ) andstores it in the ftemp field. setFahrenheit —The setFahrenheit method accepts a Fahrenheit temperature (as adouble ) and stores it in the ftemp field. getFahrenheit —Returns the value of the ftemp field, as a Fahrenheit temperature (noconversion required). getCelsius —Returns the value of the ftemp field converted to Celsius. getKelvin —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)) _ 273Demonstrate the Temperature class by writing a separate program that asks the user for aFahrenheit 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 callthe object’s methods to display the temperature in Celsius and Kelvin.USING BLUE J PROVIDE TWO SOURCE CODE SHOWING RELATIONSHIP OF THE CODE AND OUTPUT. ONE CODE WITH TEMPERATURE AND OTHER WITH TEMPERATUREDEMO. IN TOTAL, YOU SHOULD SUBMIT 6 SOURCE CODE EACH HAS TWO SOURCE CODE. BELOW IS THE SAMPLE OF HOW SHOULD LOOKpublic class HelloWorldDemo{public static void main(String [] args) {HelloWorld myMessage = new HelloWorld();System.out.println(myMessage.getMessage());}}public class HelloWorld{private final String MSG="Hello World";public String getMessage(){return MSG;}}

1 Answer

3 votes

Answer: Thermometer

Step-by-step explanation:

User Toothie
by
5.4k points