Fahrenheit to celsius java – Java Program to Convert Fahrenheit to Celsius

Fahrenheit to celsius java: Interested in programming and want to excel in it by choosing the short ways. Then, practicing with the available Java Program list is mandatory.

Java Program to Convert Fahrenheit to Celsius

  • Java program to convert temperature from Fahrenheit to Celsius.
  • Write a program in java to convert temperature from Fahrenheit to Celsius.

In this java program, we have to convert fahrenheit temperature to celsius temperature scale. We will first take a fahrenheit temperature as input from user and then convert it to celsius temperature and print it on screen.

For Example,
80 Fahrenheit is equal to 26.6667 Celsius

  • Fahrenheit temperature scale was introduced around 300 years ago and is currently used in US. The boiling point of water is 212 °F and the freezing point of water is 32 °F.
  • Celsius is a temperature scale where 0 °C indicates the melting point of ice and 100 °C indicates the steam point of water.

Given a temperature in celsius, we can convert to fahrenheit scale using following equation.

C = (F – 32)*(5/9)

where, F is temperature in fahrenheit and C is temperature in celsius.

Java program to convert fahrenheit to celsius temperature

Java program to convert fahrenheit to celsius temperature

package com.tcc.java.programs;
 
import java.util.Scanner;
 
/**
 * Java Program to convert temperature from Fahrenheit to Celsius
 */
public class FahrenToCelcius {
    public static void main(String args[]) {
        float celsius, fahren;
        Scanner scanner;
        scanner = new Scanner(System.in);
        // Take fahrenheit temperature input from user
        System.out.println("Enter Temperature in Fahrenheit");
        fahren = scanner.nextFloat();
 
        celsius = 5 * (fahren - 32) / 9;
 
        System.out.print("Temperature in Celsius = " + celsius);
    }
}

Output

Enter Temperature in Fahrenheit
32
Temperature in Celsius = 0.0
Enter Temperature in Fahrenheit
100
Temperature in Celsius = 37.77778