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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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