Question: JAVA - Define a private helper method called convertToCelsius ( ) that converts the field fahrenheit to Celsius and returns a double. Ex: If the

JAVA
-
Define a private helper method called convertToCelsius() that converts the field fahrenheit to Celsius and returns a double.
Ex: If the input is 280.0, then the output is:
137.6 degrees Celsius
Note: The equation to convert from Fahrenheit to Celsius is: celsius =(fahrenheit -32)*0.555
public class Weather {
private double fahrenheit;
public void setFahrenheit(double inputFahrenheit){
fahrenheit = inputFahrenheit;
}
public double getFahrenheit(){
return fahrenheit;
}
/* Your code goes here */
public void printInCelsius(){
System.out.printf("%.1f degrees Celsius
", convertToCelsius());
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!