#K12281. Temperature Converter
Temperature Converter
Temperature Converter
In this problem, you are required to build a temperature converter that performs two types of conversions:
- Convert a temperature from Fahrenheit to Celsius using the formula \(C = \frac{5}{9}(F-32)\).
- Convert a temperature from Celsius to Fahrenheit using the formula \(F = \frac{9}{5}C+32\).
The input begins with an integer \(T\) representing the number of queries. Each of the following \(T\) lines contains a conversion type and a temperature value separated by a space. The conversion type is a single character: 'F' indicates that the provided temperature is in Fahrenheit and should be converted to Celsius, and 'C' indicates that it is in Celsius and should be converted to Fahrenheit.
For each query, output the converted temperature on a new line. The answer should be printed as a floating-point number formatted to one decimal place.
inputFormat
The first line contains an integer \(T\) indicating the number of queries. Each of the following \(T\) lines contains a character and a floating point number separated by a space. The character is either 'F' or 'C':
- 'F' means the input is in Fahrenheit and must be converted to Celsius.
- 'C' means the input is in Celsius and must be converted to Fahrenheit.
outputFormat
For each query, output the converted temperature on a separate line. The result should be a floating-point number formatted to one decimal place.
## sample4
F 32
F 104.9
C 0
C 40.5
0.0
40.5
32.0
104.9
</p>