Jump to content

Temperature conversion: Difference between revisions

m
→‎{{header|REXX}}: simplified uppercasing of some none-Latin characters, added whitespace. -- ~~~~
m (→‎{{header|REXX}}: added whitespace. -- ~~~~)
m (→‎{{header|REXX}}: simplified uppercasing of some none-Latin characters, added whitespace. -- ~~~~)
Line 257:
x=space(x); parse var x z '(' /*handle any comments (if any). */
if z=='' then call serr 'no arguments were specified.'
_ = verify(z, '+-.0123456789') /*alla thelist legalof valid number thingys. */
 
if _\==0 then do
if _==1 then call serr 'illegal temperature:' #
n= left(z,_-1) /*pick off the number (hopefully)*/
u= strip(substr(z,_)) /*pick off the temperature unit. */
end
else u= 'k' /*assume Kelvin as per task req.*/
 
uU=translate(u,'EE',"éÉ"); upper uU /*uppercase version of temp unit.*/
if left(uU,7)=='DEGREES' then uU=substr(uU,8) /*redundant "degrees"? */
if left(uU,5)=='DEGREE' then uU=substr(uU,7) /* " " degree" ? */
uU=strip(uU)
if \datatype(n,'N') then call serr 'illegal number:' n
/*accept alternate spellings. */
select /*convert ──► ºF temperatures. */
when abbrev('CENTIGRADE', uU) |,
abbrev('CENTESIMAL', uU) |,
abbrev('CELSIUS' , uU) |,
abbrev('CELCIUS' , uU) then F=n * 9/5 + 32
when abbrev('DELISLE' , uU) then F=212 -(n * 6/5)
Line 283:
when abbrev('RANKINE' , uU) then F=n - 459.67
when abbrev('REAUMUR' , uU, 2) then F=n * 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('ROEMER' , uU, 2) |,
abbrev('ROMER' , uU, 2) then F=(n-7.5) * 27/4 + 32
Line 291 ⟶ 288:
end /*select*/
say right(' ' x,55,"─")
say Tform( ( F - 32) ) * 5/9 ) 'Celcius'
say Tform( ( 212 - F) ) * 5/6 ) 'Delisle'
say Tform( F ) 'Fahrenheit'
say Tform( ( F + 459.67 ) * 5/9 ) 'Kelvin'
say Tform( ( F - 32 ) * 11/60 ) 'Newton'
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=''*/
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.