Anonymous user
Temperature conversion: Difference between revisions
Added solution for Action!
(Added solution for Action!) |
|||
Line 185:
-421.87000 degrees Fahrenheit
37.80000 degrees Rankine
</pre>
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
<lang Action!>INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
PROC K2C(REAL POINTER k,c)
REAL tmp
ValR("273.15",tmp)
RealSub(k,tmp,c)
RETURN
PROC K2F(REAL POINTER k,f)
REAL tmp1,tmp2,tmp3
ValR("1.8",tmp1)
ValR("459.67",tmp2)
RealMult(k,tmp1,tmp3)
RealSub(tmp3,tmp2,f)
RETURN
PROC K2R(REAL POINTER k,f)
REAL tmp
ValR("1.8",tmp)
RealMult(k,tmp,f)
RETURN
PROC Test(CHAR ARRAY text REAL POINTER k)
REAL res
PrintE(text)
Print(" Kelvin: ") PrintRE(k)
K2C(k,res)
Print(" Celsius: ") PrintRE(res)
K2F(k,res)
Print(" Fahrenheit: ") PrintRE(res)
K2R(k,res)
Print(" Rankine: ") PrintRE(res)
PutE()
RETURN
PROC Main()
REAL k
Put(125) PutE() ;clear screen
ValR("0",k) Test("Absolute zero",k)
ValR("273.15",k) Test("Ice melts",k)
ValR("373.15",k) Test("Water boils",k)
RETURN
</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Temperature_conversion.png Screenshot from Atari 8-bit computer]
<pre>
Absolute zero
Kelvin: 0
Celsius: -273.15
Fahrenheit: -459.67
Rankine: 0
Ice melts
Kelvin: 273.15
Celsius: 0
Fahrenheit: 32
Rankine: 491.67
Water boils
Kelvin: 373.15
Celsius: 100
Fahrenheit: 212
Rankine: 671.67
</pre>
|