There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones:
Kelvin, Celsius, Fahrenheit, and Rankine.

The Celsius and Kelvin scales have the same magnitude, but different null points.

 0 degrees Celsius corresponds to 273.15 kelvin.
 0 kelvin is absolute zero.
The Fahrenheit and Rankine scales also have the same magnitude, but different null points.

 0 degrees Fahrenheit corresponds to 459.67 degrees Rankine.
 0 degrees Rankine is absolute zero.
The Celsius/Kelvin and Fahrenheit/Rankine scales have a ratio of 5 : 9.



Task
Write code that accepts a value of kelvin, converts it to values of the three other scales, and prints the result.



Example

K  21.00

C  -252.15

F  -421.87

R  37.80



/* NetRexx */
options replace format comments java crossref symbols
 
numeric digits 20
 
runSample(arg)
return
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
  +  Kelvin               Celsius        Fahrenheit      Rankine             Delisle        Newton            Réaumur        Rømer
  K  T                    T-273.15       T*9/5-459.67    T*9/5               (373.15-T)*3/2 (T-273.15)*33/100 (T-273.15)*4/5 (T-273.15)*21/40+7.5
  C  T+273.15             T              T*9/5+32        (T+273.15)*9/5      (100-T)*3/2    T*33/100          T*4/5          T*21/40+7.5
  F  (T+459.67)*5/9       (T-32)*5/9     T               T+459.67            (212-T)*5/6    (T-32)*11/60      (T-32)*4/9     (T-32)*7/24+7.5
  R  T*5/9                (T-491.67)*5/9 T-459.67        T                   (671.67-T)*5/6 (T-491.67)*11/60  (T-491.67)*4/9 (T-491.67)*7/24+7.5
  De 373.15-T*2/3         100-T*2/3      212-T*6/5       671.67-T*6/5        T              33-T*11/50        80-T*8/15      60-T*7/20
  N  T*100/33+273.15      T*100/33       T*60/11+32      T*60/11+491.67      (33-T)*50/11   T                 T*80/33        T*35/22+7.5
  Ré T*5/4+273.15         T*5/4          T*9/4+32        T*9/4+491.67        (80-T)*15/8    T*33/80           T              T*21/32+7.5
  Rø (T-7.5)*40/21+273.15 (T-7.5)*40/21  (T-7.5)*24/7+32 (T-7.5)*24/7+491.67 (60-T)*20/7    (T-7.5)*22/35     (T-7.5)*32/21  T
 */
method temperatureConversion(scaleFrom, scaleTo, T) public static
 
  parse 'KELVIN CELSIUS FAHRENHEIT RANKINE DELISLE NEWTON REAUMUR ROEMER' -
         KELVIN CELSIUS FAHRENHEIT RANKINE DELISLE NEWTON REAUMUR ROEMER .
  scaleFrom = scaleFrom.upper()
  scaleTo   = scaleTo.upper()
  select label sF case scaleFrom
    when KELVIN then do
      select case scaleTo
        when KELVIN     then val = T
        when CELSIUS    then val = T - 273.15
        when FAHRENHEIT then val = T * 9 / 5 - 459.67
        when RANKINE    then val = T * 9 / 5
        when DELISLE    then val = (373.15 - T) * 3 / 2
        when NEWTON     then val = (T - 273.15) * 33 / 100
        when REAUMUR    then val = (T - 273.15) * 4 / 5
        when ROEMER     then val = (T - 273.15) * 21 / 40 + 7.5
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    when CELSIUS then do
      select case scaleTo
        when KELVIN     then val = T + 273.15
        when CELSIUS    then val = T
        when FAHRENHEIT then val = T * 9 / 5 + 32
        when RANKINE    then val = (T + 273.15) * 9 / 5
        when DELISLE    then val = (100 - T) * 3 / 2
        when NEWTON     then val = T * 33 / 100
        when REAUMUR    then val = T * 4 / 5
        when ROEMER     then val = T * 21 / 40 + 7.5
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    when FAHRENHEIT then do
      select case scaleTo
        when KELVIN     then val = (T + 459.67) * 5 / 9
        when CELSIUS    then val = (T - 32) * 5 / 9
        when FAHRENHEIT then val = T
        when RANKINE    then val = T + 459.67
        when DELISLE    then val = (212 - T) * 5 / 6
        when NEWTON     then val = (T - 32) * 11 / 60
        when REAUMUR    then val = (T - 32) * 4 / 9
        when ROEMER     then val = (T - 32) * 7 / 24 + 7.5
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    when RANKINE then do
      select case scaleTo
        when KELVIN     then val = T * 5 / 9
        when CELSIUS    then val = (T - 491.67) * 5 / 9
        when FAHRENHEIT then val = T - 459.67
        when RANKINE    then val = T
        when DELISLE    then val = (671.67 - T) * 5 / 6
        when NEWTON     then val = (T - 491.67) * 11 / 60
        when REAUMUR    then val = (T - 491.67) * 4 / 9
        when ROEMER     then val = (T - 491.67) * 7 / 24 + 7.5
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    when DELISLE then do
      select case scaleTo
        when KELVIN     then val = 373.15 - T * 2 / 3
        when CELSIUS    then val = 100 - T * 2 / 3
        when FAHRENHEIT then val = 212 - T * 6 / 5
        when RANKINE    then val = 671.67 - T * 6 / 5
        when DELISLE    then val = T
        when NEWTON     then val = 33 - T * 11 / 50
        when REAUMUR    then val = 80 - T * 8 / 15
        when ROEMER     then val = 60 - T * 7 / 20
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    when NEWTON then do
      select case scaleTo
        when KELVIN     then val = T * 100 / 33 + 273.15
        when CELSIUS    then val = T * 100 / 33
        when FAHRENHEIT then val = T * 60 / 11 + 32
        when RANKINE    then val = T * 60 / 11 + 491.67
        when DELISLE    then val = (33 - T) * 50 / 11
        when NEWTON     then val = T
        when REAUMUR    then val = T * 80 / 33
        when ROEMER     then val = T * 35 / 22 + 7.5
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    when REAUMUR then do
      select case scaleTo
        when KELVIN     then val = T * 5 / 4 + 273.15
        when CELSIUS    then val = T * 5 / 4
        when FAHRENHEIT then val = T * 9 / 4 + 32
        when RANKINE    then val = T * 9 / 4 + 491.67
        when DELISLE    then val = (80 - T) * 15 / 8
        when NEWTON     then val = T * 33 / 80
        when REAUMUR    then val = T
        when ROEMER     then val = T * 21 / 32 + 7.5
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    when ROEMER then do
      select case scaleTo
        when KELVIN     then val = (T - 7.5) * 40 / 21 + 273.15
        when CELSIUS    then val = (T - 7.5) * 40 / 21
        when FAHRENHEIT then val = (T - 7.5) * 24 / 7 + 32
        when RANKINE    then val = (T - 7.5) * 24 / 7 + 491.67
        when DELISLE    then val = (60 - T) * 20 / 7
        when NEWTON     then val = (T - 7.5) * 22 / 35
        when REAUMUR    then val = (T - 7.5) * 32 / 21
        when ROEMER     then val = T
        otherwise       signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
        end
      end
    otherwise
      signal IllegalArgumentException(scaleFrom',' scaleTo',' T)
    end sF
 
  return val
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) public static
 
  tlist = [ -
  /* C....... F....... K....... R.......*/ -
    ' 5500.00  9932.00  5773.15 10391.67', -
    '  300.00   572.00   573.15  1031.67', -
    '  200.00   392.00   473.15   851.67', -
    '  100.00   212.00   373.15   671.67', -
    '   37.00    98.60   310.15   558.27', -
    '    0.00    32.00   273.15   491.67', -
    ' -100.00  -148.00   173.15   311.67', -
    ' -200.00  -328.00    73.15   131.67', -
    ' -252.15  -421.87    21.00    37.80', -
    ' -273.15  -459.67     0.00     0.00'  -
    ]
 
  parse 'CELSIUS FAHRENHEIT KELVIN RANKINE' CELSIUS FAHRENHEIT KELVIN RANKINE .
  loop temp over tlist
    parse temp ttC ttF ttK ttR .
    say '   C....... F....... K....... R.......'
    say 'C ' -
        temperatureConversion(CELSIUS,    CELSIUS,    ttC).format(5, 2) -
        temperatureConversion(CELSIUS,    FAHRENHEIT, ttC).format(5, 2) -
        temperatureConversion(CELSIUS,    KELVIN,     ttC).format(5, 2) -
        temperatureConversion(CELSIUS,    RANKINE,    ttC).format(5, 2)
 
    say 'F ' -
        temperatureConversion(FAHRENHEIT, CELSIUS,    ttF).format(5, 2) -
        temperatureConversion(FAHRENHEIT, FAHRENHEIT, ttF).format(5, 2) -
        temperatureConversion(FAHRENHEIT, KELVIN,     ttF).format(5, 2) -
        temperatureConversion(FAHRENHEIT, RANKINE,    ttF).format(5, 2)
 
    say 'K ' -
        temperatureConversion(KELVIN,     CELSIUS,    ttK).format(5, 2) -
        temperatureConversion(KELVIN,     FAHRENHEIT, ttK).format(5, 2) -
        temperatureConversion(KELVIN,     KELVIN,     ttK).format(5, 2) -
        temperatureConversion(KELVIN,     RANKINE,    ttK).format(5, 2)
 
    say 'R ' -
        temperatureConversion(RANKINE,    CELSIUS,    ttR).format(5, 2) -
        temperatureConversion(RANKINE,    FAHRENHEIT, ttR).format(5, 2) -
        temperatureConversion(RANKINE,    KELVIN,     ttR).format(5, 2) -
        temperatureConversion(RANKINE,    RANKINE,    ttR).format(5, 2)
    say
    end temp
 
  return
 