Wednesday, January 29, 2014

How to convert Celsius to Fahrenheit?

Source:
class CelsiusToFahrenheit {

  public static void main(String[] args) {

    // Water boils at this temperature
    double temp = 100;
    System.out.println("Celsius: " + temp);
 
    temp = temp * 9 / 5 + 32;
    System.out.println("Fahrenheit: " + temp);
 
  }
}

Output:
   $ java CelsiusToFahrenheit 
  Celsius: 100.0
  Fahrenheit: 212.0

Blog Archive