Write a class to convert Fahrenheit temperature to Celsius. Declare a variable to hold the normal human body temperature of 98.6 degrees Fahrenheit. A Celsius temperature can be calculated by subtracting 32 from the Fahrenheit value and multiplying the result by 5.0/9.0. Display the converted Celsius value. Save the class as FahrenheitToCelsius.java.
public class FahrenheitToCelsius {
/** Main Method */
public static void main(String[] args) {
double fahrenheit = 98.6;
double celsius = (fahrenheit - 32.0) * (5.0 / 9.0);
System.out.println("The normal human body temperature of 98.6 degrees Fahrenheit");
System.out.printf("The normal human body temperature of %.2f degrees Celsius\n", celsius);
}
}
Comments
thankyou for the answer
Leave a comment