Java Programs

Convert Fahrenheit into Celsius Program in Java

In this tutorial, we are going to learn a python program to convert Fahrenheit into Celsius. This program will be simple because we have a Fahrenheit to Celsius conversion formula for this temperature conversion. We will use this conversion formula in our java program for this conversion.

Our Fahrenheit to Celsius conversion program behavior?

  1. Our Java program will take a Fahrenheit temperature as an input.
  2. Now we will use Fahrenheit to Celsius conversion formula which is ((fahrenheit32)*5)/9.
  3. After applying the above formula, result will be a temperature in Celsius.

Java Program to Convert Fahrenheit into Celsius

import java.util.*;

public class Main {

    public static void main(String[] args) {
    	
        float celsius, fahrenheit;
        System.out.println("Program to convert Fahrenheit to Celsius" );
        Scanner sc = new Scanner(System.in);
        System.out.println("Please give the Fahrenheit Temperature");
        fahrenheit= sc.nextFloat();
        celsius = ((fahrenheit-32)*5)/9;
        System.out.printf("Celsius = %.2f",celsius);
    }
}

Output

Program to convert Fahrenheit to Celsius
Please give the Fahrenheit Temperature
96.8
Celsius = 36.00

Explanation

For the input Fahrenheit temperature 96.8.

Celsius temperature = ((96.8 -32)*5)/9 = 36.00

About the Author: Elavarasan PK

Technical Specialist, Intersoft Data Labs