In this tutorial, we will see simple java program to convert fahrenheit to celsius in java.
You can convert fahrenheit to celsius using this formula.
cel = (fh-32) / 1.8;
import java.util.Scanner;
public class TempConvertor
{
public static void main(String args[])
{
float fh;
double cel;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Temperature in Fahrenheit : ");
fh = scanner.nextFloat();
cel = (fh-32) / 1.8;
System.out.print("Equivalent Temperature in Celsius : " + cel);
}
}
Output:
Enter Temperature in Fahrenheit : 79
Equivalent Temperature in Celsius : 26.11111111111111
Equivalent Temperature in Celsius : 26.11111111111111