98 854
Assignments Done
98.6%
Successfully Done
In April 2021

# Answer to Question #16373 in Java | JSP | JSF for Abdullah Almousawi

Question #16373
(Temperature Class) Create a class called Temperature that is used to convert temperatures from/to Celsius/Fahrenheit. Temperature should include one instance variable&mdash; temperature degree (type double). Your class should have a constructor that initializes instance variable. Provide set and get methods for it. In addition, provide the following two methods
 toCelsius() that converts and returns the temperature degree in Celsius.
 toFahrenheit()that converts and returns the temperature degree in Fahrenheit.
Write a test application named TemperatureTest that demonstrate the following sample output using Temperature class.
1
2012-10-15T11:39:57-0400
import java.util.Scanner;

public class Main {
/**
& *@param farenheit int& temperatur
*/
& public static double toCelsius(int farenheit) {
& double res=0.0;
& res=(farenheit-32)*5/9;
& return res;
& }
&
& /**
& *@param celsium int& temperatur
*/
& public static double toFahrenheit(int celsium) {
& double res=0.0;
& res=(celsium+32)*5/9;
& return res;
& }
/**
& * @param args
& */
public static void main(String[] args) {
& // TODO Auto-generated method stub
& int celsium=0,farenheit=0, conwertCelsium=0,conwertFarenheit=0;
& Scanner sc =new Scanner (System.in);
& System.out.println(&quot;Input temperatur in C &quot;);
& celsium=sc.nextInt();
& System.out.println(&quot;Resoult& in F &quot;+ toFahrenheit(celsium));
& System.out.println(&quot;Input temperatur in F &quot;);
& farenheit=sc.nextInt();
& System.out.println(&quot;Resoult& in C &quot;+ toCelsius(farenheit));
&
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!