Temperature Conversion - Celsius to Fahrenheit - Fahrenheit to Celsius

Temperature Conversion - Celsius to Fahrenheit ? Fahrenheit to Celsius


Temperature Conversion - Celsius to Fahrenheit ? Fahrenheit to Celsius

Graphic Source: USA TODAY

Water freezes at 0? Celsius and boils at 100? Celsius which is a difference of 100?. Water freezes at 32? Fahrenheit and boils at 212? Fahrenheit which is a difference of 180?. Therefore each degree on the Celsius scale is equal to 180/100 or 9/5 degrees on the Fahrenheit scale.

There are no predefined functions in CFML for this, so we have to write some lines of code for it.


<!--- Celsius to Fahrenheit --->
<cfset Celsius_convert = 37>

<cfset Fahrenheit = (9/5) * #Celsius_convert# + 32>


<cfoutput>Celsius #Celsius_convert# = #Fahrenheit# Fahrenheit</cfoutput><br />

<!--- Fahrenheit to Celsius --->
<cfset Fahrenheit_convert = 98.6>

<cfset Celsius = (5/9) * (#Fahrenheit_convert# -32)>

<cfoutput>Fahrenheit #Fahrenheit_convert# = #Celsius# Celsius</cfoutput>


The output:

Celsius 37 = 98.6 Fahrenheit
Fahrenheit 98.6 = 37 Celsius

Advertisement

Hot Offer

No User Comments.

No User Comments, be the first one to write your comments?

ApplayIT is owned by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.