Convert fahrenheit to celsius in java

In this tutorial, we will see simple java program to convert fahrenheit to celsius in java.
You can convert fahrenheit to celsius using this formula.

cel = (fh-32) / 1.8;
import java.util.Scanner;

public class TempConvertor
{
    public static void main(String args[])
    {
        float fh;
        double cel;
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter Temperature in Fahrenheit : ");
        fh = scanner.nextFloat();

        cel = (fh-32) / 1.8;

        System.out.print("Equivalent Temperature in Celsius : " + cel);
    }
}

Output:

Enter Temperature in Fahrenheit : 79
Equivalent Temperature in Celsius : 26.11111111111111
[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.