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

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

Recommended Posts
Java Program to Convert Celsius to Fahrenheit
Java Program to Calculate Compound Interest
Java Program to Calculate Simple Interest
Java Program to Convert Decimal to Binary Numbers
Java program to convert binary number to decimal number
Java Program to Convert Octal Number to Decimal Number
Java Program to Find Area of Right Angled Triangle
Java Program to Find Area Of Triangle
Java Program to Calculate Volume of Sphere
Java Program to Find Surface Area and Volume of Cylinder
Java Program to Make a Simple Calculator using Switch Statement
All Java Programs