#C13649. Temperature Conversion
Temperature Conversion
Temperature Conversion
You are required to implement a temperature conversion program. The program will convert a temperature from one unit to another among Celsius (C), Fahrenheit (F), and Kelvin (K). The conversion formulas are given in LaTeX format as follows:
- Celsius to Fahrenheit: \( F = \frac{9}{5} \times C + 32 \)
- Fahrenheit to Celsius: \( C = \frac{5}{9} \times (F - 32) \)
- Celsius to Kelvin: \( K = C + 273.15 \)
- Kelvin to Celsius: \( C = K - 273.15 \)
For conversions that do not involve a unit change (e.g. from C to C), simply output the same value.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains a temperature conversion query with three tokens: a floating-point number (value) and two characters (from_unit and to_unit). The tokens are separated by spaces. Valid units are C
(Celsius), F
(Fahrenheit), and K
(Kelvin).
outputFormat
For each test case, output the converted temperature as a floating-point number on a new line, formatted to three decimal places.
## sample7
100 C F
0 F K
273.15 K C
32 F C
100 C K
373.15 K F
50 F F
212.000
255.372
0.000
0.000
373.150
212.000
50.000
</p>