CODE
class TemperatureConversion
{
public static void main(String arg[])
{
double fahrenheit = 98.4;
double celsius = ( 5.0 * (fahrenheit - 32.0) ) / 9.0;
System.out.println(fahrenheit + " F is same as " + celsius + " C.");
}
}
98.4 F is same as 36.888888888888886 C.
Here we have declared a variable fahrenheit
and initialized to 98.4
. Then we are using the formula to convert from fahrenheit
to celsius
. And finally we are printing the result.
fahrenheit
value from 98.4
to 104.0
and see what is the output.celsius
to fahrenheit
. The formula will be F = (( 9.0 * C ) / 5.0) + 32.0