Numbers - Converting Celsius to Fahrenheit and
(Page 9 of 12 )
>1.11 Converting Celsius to Fahrenheit
You have a temperature reading measured in Celsius and need to convert it to Fahrenheit.
Solution >
public static double CtoF(double celsius)
{
return (((0.9/0.5) * celsius) + 32);
}
Discussion >
This recipe makes use of the following Celsius-to-Fahrenheit temperature conversion equation:
TempCelsius = (5 / 9) * (TempFahrenheit - 32)
The Fahrenheit temperature scale is widely used in the United States. However, much of the rest of the world uses the Celsius temperature scale.
1.12 Converting Fahrenheit to Celsius Problem >You have a temperature reading measured in Fahrenheit and need to convert it to Celsius.
Solution >
public static double FtoC(double fahrenheit)
{
return ((0.5/0.9) * (fahrenheit - 32));
}
Discussion >
This recipe makes use of the following Fahrenheit-to-Celsius temperature conversion equation:
TempFahrenheit = ((9 / 5) * TempCelsius) + 32
The Fahrenheit temperature scale is widely used in the United States. However, much of the rest of the world uses the Celsius temperature scale.
 | If you've enjoyed what you've seen here, or to get more information, click on the "Buy the book!" graphic. Pick up a copy today!
Visit the O'Reilly Network http://www.oreillynet.com for more online content. |