You are here

Java program to convert Fahrenheit to Celsius

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

Java programming code

  1. import java.util.*;
  2.  
  3. class FahrenheitToCelsius {
  4.   public static void main(String[] args) {
  5.     float temperature;
  6.     Scanner in = new Scanner(System.in);
  7.  
  8.     System.out.println("Enter temperature in Fahrenheit");
  9.     temperature = in.nextInt();
  10.  
  11.     temperature = ((temperature - 32)*5)/9;
  12.  
  13.     System.out.println("temperature in Celsius = " + temperature);
  14.   }
  15. }

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.