Fahrenheit to Celsius Conversion Program in Java

Fahrenheit to Celsius Conversion Program in Java

In this tutorial, you are going to learn to write Java Program to convert a given temperature from Fahrenheit to Celsius.

For Example:

Suppose the given temperature in Fahrenheit is 86

Now Fahrenheit to Celsius conversion Formulae is : ((Fahrenheit-32)*5)/9

So,

((86-32)*5)/9 = 30 Celsius

Java Program to convert Temperature from Fahrenheit to Celsius

import java.util.*;
public class Main
{
    public static void main(String[] args) {
        float celsius, fahrenheit;
        System.out.println("Fahrenheit to Celsius Conversion Java Program" );
        Scanner sc = new Scanner(System.in);
        System.out.println("Give Tempreture in Fahrenheit");
        fahrenheit= sc.nextFloat();
        celsius = ((fahrenheit-32)*5)/9;
        System.out.printf("Tempreture in Celsius = %.2f",celsius);
    }
}

Output

Fahrenheit to Celsius Conversion Java Program
Give Tempreture in Fahrenheit
86
Tempreture in Celsius = 30.00