Friday, July 27, 2012

Temperature Conversion Library in Java

This library allows you to perform conversion between the Celsius, Kelvin, Rankine, Delisile, Newton, Reaumur, Romer and Fahrenheit temperature scales.

Here's an example on how to use the library:
package temperatureconversion;

public class TestLauncher
{
    public static void main(String[] args)
    {
        Temperature t1 = Temperature.fromCelsius(-273.15);
        Temperature t2 = Temperature.fromKelvin(0.0);
        System.out.println("Kelvin degrees    : " + t1.toKelvin()     +"\n" +
                           "Celsius degrees   : " + t1.toCelsius()    +"\n" +
                           "Delisle degrees   : " + t1.toDelisle()    +"\n" +
                           "Newton degrees    : " + t1.toNewton()     +"\n" +
                           "Rankine degrees   : " + t1.toRankine()    +"\n" +
                           "Reaumur degrees   : " + t1.toReaumur()    +"\n" +
                           "Fahrenheit degrees: " + t1.toFahrenheit() +"\n" +
                           "Romer degrees     : " + t1.toRomer()      +"\n" );
        System.out.println("Kelvin degrees    : " + t2.toKelvin()     +"\n" +
                           "Celsius degrees   : " + t2.toCelsius()    +"\n" +
                           "Delisle degrees   : " + t2.toDelisle()    +"\n" +
                           "Newton degrees    : " + t2.toNewton()     +"\n" +
                           "Rankine degrees   : " + t2.toRankine()    +"\n" +
                           "Reaumur degrees   : " + t2.toReaumur()    +"\n" +
                           "Fahrenheit degrees: " + t2.toFahrenheit() +"\n" +
                           "Romer degrees     : " + t2.toRomer()      +"\n" );
    }
}

No comments:

Post a Comment

Got a question regarding something in the article? Leave me a comment and I will get back at you as soon as I can!

Related Posts Plugin for WordPress, Blogger...
Recommended Post Slide Out For Blogger