on Leave a Comment

Java Program to Convert Fahrenheit to Celsius

This java program converts Fahrenheit to Celsius. First, user enters the temperature in Fahrenheit and this temperature is converting into Celsius temperature using simple formula:

f = c * 9/5 + 32;

Here is source code that converts temperature in Fahrenheit to Celsius.

Java Program to Convert Fahrenheit to Celsius

import java.util.Scanner;

public class FahrenheitToCelsius
{
    public static void main(String args[])
    {
        double fah;
        double cel;
  
        System.out.print("Enter Temperature in Fahrenheit : ");

        Scanner read = new Scanner(System.in);
        fah = read.nextFloat();
  
        cel = (fah-32) / 1.8;
  
        System.out.print("Temperature in Celsius = " + cel);
    }
}

Output:

Enter Temperature in Fahrenheit : 67
Temperature in Celsius = 19.444444444444443

0 comments:

Post a Comment