#K52472. Temperature Bidirectional Conversion

    ID: 29317 Type: Default 1000ms 256MiB

Temperature Bidirectional Conversion

Temperature Bidirectional Conversion

In this problem, you are given several temperature conversion queries. Each query consists of a conversion type and a temperature value. If the conversion type is F, you should convert the temperature from Fahrenheit to Celsius; if the conversion type is C, you need to convert the temperature from Celsius to Fahrenheit.

The conversion formulas are given by:

  • Fahrenheit to Celsius: $$ C = \frac{5}{9}(F - 32) $$
  • Celsius to Fahrenheit: $$ F = \frac{9}{5}C + 32 $$

For each conversion, output the result rounded to two decimal places.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer T, the number of test cases.
  • Each of the following T lines contains a conversion query in the format: {type} {value} where {type} is a single character: F for Fahrenheit to Celsius conversion or C for Celsius to Fahrenheit conversion, and {value} is a floating-point number representing the temperature to be converted.

outputFormat

For each query, output one line to stdout containing the converted temperature rounded to two decimal places.## sample

4
F 32
C 0
F 212
C 37.78
0.00

32.00 100.00 100.00

</p>