The Java code for this temperature conversion from Fahrenheit to Celsius is given below. the code starts by asking the user to enter a temperature in Fahrenheit scale and then displays the equivalent Celsius Temperature.
Hope that the Java code provide for conversion from Fahrenheit to Celsius was useful to you all.
Code:
/////////////////////////////////
package developer;
import java.util.Scanner;
public class FahrenheitToCelsius {
public static void main(String[] args) {
System.out.println("Enter a temperature in Fahrenheit: ");
Scanner scanFaren = new Scanner(System.in);
double Celsius = 0;
if(scanFaren.hasNextDouble())
{
Celsius = (scanFaren.nextDouble() - 32)*5/9;
}
System.out.println("The temperature in Celsius is: "+Celsius);
}
}
/////////////////////////////////
When this Java Code was executed on my JVM, then the output was as shown below.
/////////////////////////////////
Enter a temperature in Fahrenheit:
56
The temperature in Celsius is: 13.333333333333334
/////////////////////////////////
Hope that the Java code provide for conversion from Fahrenheit to Celsius was useful to you all.