You are here

Java program to convert Fahrenheit to Celsius

Java program to convert Fahrenheit to Celsius: This code does temperature conversion from the Fahrenheit scale to the Celsius scale. For Celsius to Fahrenheit conversion use:
T = 9*T/5 + 32
'T' is the temperature on the Celsius scale.

Java temperature conversion program

import java.util.*;

class FahrenheitToCelsius {
  public static void main(String[] args) {
    float temperature;
    Scanner in = new Scanner(;

    System.out.println("Enter temperature in Fahrenheit");
    temperature = in.nextInt();

    temperature = ((temperature - 32)*5)/9;

    System.out.println("temperature in Celsius = " + temperature);

Download Fahrenheit to Celsius program class file.

Output of program:
Fahrenheit to Celsius Java program output

Create and test Fahrenheit to Celsius program yourself for practice.