Temperature conversion: Difference between revisions

→‎{{header|REXX}}: added other temperature scales to the REXX program, added a nit at the bottom of the output. -- ~~~~
m (→‎{{header|REXX}}: output needs updating... -- ~~~~)
(→‎{{header|REXX}}: added other temperature scales to the REXX program, added a nit at the bottom of the output. -- ~~~~)
Line 240:
* (alternate spellings with optional   ''degrees''):
** Centingrade, centesimal, Celsius, Celcius
** Delisle
** Fahrenheit
** Kelvin
** Newton
** Rankine
** Reaumur, Réaumur
** Romer   (Romer)
* multiple temperatures in a list
* comments within the list
* aligned output (whole numbers and decimal fractions)
<lang rexx>/*REXX program converts units of temperature for: C, D, F, N, RRa, Re, Ro, and K. */
parse arg tList /*get specified temperature lists*/
 
Line 264 ⟶ 267:
 
uU=u; upper uU /*uppercase version of temp unit.*/
if left(uU,7)=='DEGREES' then uU=substr(uU,8) /*reduntantredundant "degrees"? */
if left(uU,5)=='DEGREE' then uU=substr(uU,7) /*reduntant "degree " ? */
uU=strip(uU)
if \datatype(n,'N') then call serr 'illegal number:' n
/*accept alternate spellings. */
select select /*convert ───◄──► ºF commontemperatures. temperature*/
when abbrev('CENTIGRADE', uU) |,
abbrev('CENTESIMAL', uU) |,
abbrev('CELSIUS' , uU) |,
abbrev('CELCIUS' , uU) then F = n * 1.8 9/5 + 32
when abbrev('FAHRENHEITDELISLE' , uU) then F =212 -(n * 6/5)
when abbrev('KELVINFAHRENHEIT' , uU) then F = n * 1.8 - 459.67
when abbrev('RANKINEKELVIN' , uU) then F =n n * 9/5 - 459.67
when abbrev('REAUMURNEWTON' , uU, 2uU) then F = n * 2.2560/11 + 32
when abbrev('RANKINE' , uU) then F=n otherwise call serr 'illegal temperature scale:' - u459.67
when abbrev('REAUMUR' , uU, 2) then F=n end /*select* 9/4 + 32
when abbrev('RéAUMUR' , uU, 2) |,
abbrev('RÉAUMUR' , uU, 2) |,
abbrev('REAUMUR' , uU, 2) then F=n * 9/4 + 32
when abbrev('ROMER' , uU, 2) then F=(n-7.5) * 27/4 + 32
otherwise call serr 'illegal temperature scale:' u
end /*select*/
say right(' ' x,55,"─")
say Tform((F - 32) * 5/9 1.8 ) 'Celcius'
say Tform( (212-F) * 5/6 ) 'FahrenheitDelisle'
say Tform(( F + 459.67) * 1.8 ) 'KelvinFahrenheit'
say Tform( (F + 459.67) * 5/9 ) 'RankineKelvin'
say Tform((F - 32 ) * 11/60 2.25 ) 'ReaumurNewton'
say Tform( F + 459.67 ) 'Rankine'
say Tform((F - 32 ) * 4/9 ) 'Reaumur'
say Tform((F - 32 ) * 7/24 + 7.5) 'Romer'
end /*until tlist=''*/
 
Line 297 ⟶ 309:
'''output''' when using the input of: <tt> -40C, 0 c (water freezes), 37C (body temp), 100 C (water boils), 21 degrees Kelvin, 0K (outer space?) </tt>
<pre style="overflow:scroll">
───────────────────────────────────────────────── -40C
 
-40 Celcius
210 Delisle
-40 Fahrenheit
233.15 Kelvin
-13.2 Newton
419.67 Rankine
-32 Reaumur
-13.5 Romer
─────────────────────────────────── 0c (water freezes)
0 Celcius
150 Delisle
32 Fahrenheit
273.15 Kelvin
0 Newton
491.67 Rankine
0 Reaumur
7.5 Romer
────────────────────────────────────── 37C (body temp)
37 Celcius
94.5 Delisle
98.6 Fahrenheit
310.15 Kelvin
12.21 Newton
558.27 Rankine
29.6 Reaumur
26.925 Romer
─────────────────────────────────── 100c (water boils)
100 Celcius
0 Delisle
212 Fahrenheit
373.15 Kelvin
33 Newton
671.67 Rankine
80 Reaumur
60 Romer
──────────────────────────────────── 21 degrees Kelvin
-252.15 Celcius
528.225 Delisle
-421.87 Fahrenheit
21 Kelvin
-83.21 Newton
37.8 Rankine
-201.72 Reaumur
-124.879 Romer
──────────────────────────────────── 0K (outer space?)
-273.15 Celcius
559.725 Delisle
-459.67 Fahrenheit
0 Kelvin
-90.14 Newton
0 Rankine
-218.52 Reaumur
-135.904 Romer
</pre>
[Actually, water freezes at 0.000089 ºC, &nbsp; and boils at 99.974 ºC.]
<br><br>