Skip to content

Instantly share code, notes, and snippets.

@0x000000AC
Created November 30, 2012 22:04
Show Gist options
  • Save 0x000000AC/4179025 to your computer and use it in GitHub Desktop.
Save 0x000000AC/4179025 to your computer and use it in GitHub Desktop.
Converts F to C. I created it to remind myself about named constants and the "final" modifier
/***********************************************
* TemperatureConverter.java
* Aaron P. Clark
*
* This program converts a Fahrenheit temp to Celcius Temp
* I created it to remind myself about named constants and
* the final modifier.
***********************************************/
public class TemperatureConverter
{
public static void main(String[] args)
{
final double FREEZING_POINT = 32.0;
final double CONVERSION_FACTOR = 5.0 / 9.0;
double fahrenheit = 50; // temperature in Fahrenheit
double celsius; // temperature in Celsius
celsius = CONVERSION_FACTOR *(fahrenheit - FREEZING_POINT);
System.out.println(fahrenheit + " degrees Fahrenheit = " +
celsius + " degrees Celsius.");
} // end main
} // end class TemperatureConverter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment