Created
November 30, 2012 22:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************************** | |
* 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