#C6514. Temperature Conversion
Temperature Conversion
Temperature Conversion
This problem requires you to convert a temperature from one unit to another. You are given a temperature in a string format along with its unit (either Celsius, denoted by C, or Fahrenheit, denoted by F), and a target unit. Your task is to convert the temperature to the target unit using the following formulas:
- From Celsius to Fahrenheit: \(F = \frac{9}{5} C + 32\)
- From Fahrenheit to Celsius: \(C = \frac{5}{9}(F - 32)\)
The result must be rounded to the nearest whole number and output as a string with the converted value immediately followed by the target unit.
If the provided conversion is invalid (i.e. when the original unit is the same as the target unit), output "Invalid unit conversion combination".
inputFormat
The input is provided via stdin and consists of two lines:
- The first line contains a temperature value followed immediately by its unit (e.g.
21C
or70F
). - The second line contains the target unit (
C
orF
).
outputFormat
Output the converted temperature as a string to stdout, where the numerical value is rounded to the nearest whole number and immediately followed by the target unit. In case of an invalid conversion (i.e. the source and target units are the same), output "Invalid unit conversion combination".
## sample21C
F
70F