In this article, we will show you how to write a Java program to convert Fahrenheit To Celsius with an example. The math formula to calculate Celsius = (Fahrenheit – 32) * 5 / 9.
The below java code accepts the temperature in Fahrenheit. Next, it uses the above mentioned math formula to convert the Fahrenheit to Celsius degrees.
package Remaining;
import java.util.Scanner;
public class FahrenheitToCelsius {
private static Scanner sc;
public static void main(String[] args) {
sc= new Scanner(System.in);
System.out.print("Enter the Temperature in Fahrenheit = ");
double fahrenheit = sc.nextDouble();
double celsius = (fahrenheit - 32) * 5 / 9;
System.out.println("Temperature in Fahrenheit = " + fahrenheit);
System.out.println("Temperature in Celsius = " + celsius);
}
}
