Java Program to Convert Fahrenheit to Celsius

This post covers a program in Java that converts the temperature entered by user in Fahrenheit, to its equivalent Celsius value.

The formula to convert Fahrenheit to Celsius is:

C = (F-32)/1.8

where C is Celsius value, and F is Fahrenheit value. Still, if you want to explore the formula, then refer to Celsius to Fahrenheit Formula Explained.

Fahrenheit to Celsius Conversion in Java

The question is, write a Java program to convert the temperature from Fahrenheit to Celsius. The Fahrenheit value must be received by user at run-time of the program. The program given below is its answer:

import java.util.Scanner;

public class CodesCracker
   public static void main(String[] args)
      float fahrenheit, celsius;
      Scanner scan = new Scanner(;
      System.out.print("Enter the Temperatur (in Fahrenheit): ");
      fahrenheit = scan.nextFloat();
      celsius = (float) ((fahrenheit-32)/1.8);
      System.out.println("\nEquivalent Temperature (in Celsius) = " +celsius);

The sample run of above program, with user input 98.6 as temperature in Fahrenheit, is shown in the snapshot given below:

java convert fahrenheit to celsius

Same Program in Other Languages

Java Online Test

« Previous Program Next Program »

Follow/Like Us on Facebook

Subscribe Us on YouTube