Wednesday, January 29, 2014

How to convert Fahrenheit to Celsius?

Source:
class FahrenheitToCelsius {

  public static void main(String[] args) {

    // body temperature
    double temp = 98.6;
    System.out.println("Fahrenheit: " + temp);

    temp = (temp - 32) * 5 / 9;

    System.out.println("Celsius: " + temp);
  }
}

Output:
   $ java FahrenheitToCelsius 
   Fahrenheit: 98.6
   Celsius: 37.0

Blog Archive