Convert “Fahrenheit to Celsius” Java Program

Today we are going to see how to convert from Fahrenheit to Celsius using a very simple Java program. This is a basic program which usually students used to study in Schools and Colleges.

There are number of ways you can write the same script, I have written it in a very simple way so you can easily memorize it. So you can helps yourselves in your exam time!

Here is the entire script:

import java.util.*;

class FahrenheitToCelsius {
  public static void main(String[] args) {
    float fahrenheit, celsius;
    Scanner in = new Scanner(System.in);      

    System.out.print("Enter Fahrenheit: ");
    fahrenheit = in.nextInt();

    celsius = (fahrenheit - 32)*5/9;

    System.out.println("Celsius = " + celsius);
  }
}

Output:

Enter Fahrenheit: 100
Celsius = 37.77778

Learn how to do the Same program “Fahrenheit to Celsius” in PHP – Click Here

 

Leave a Comment

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

Scroll to Top