#2469
Convert the Temperature
newbie · 115 · lc easy +12 · verified · 90.3% accepted · 748 likes · top 99%
Description
Given a non-negative floating-point number celsius rounded to two decimal places, convert the temperature to both Kelvin and Fahrenheit and return the results as [kelvin, fahrenheit]. Answers within 10-5 of the correct value are accepted.
Conversion formulas:
- Kelvin = Celsius + 273.15
- Fahrenheit = Celsius * 1.80 + 32.00
Example 1:
Input: celsius = 36.50
Output: [309.65000,97.70000]
Explanation: Temperature at 36.50 Celsius converted in Kelvin is 309.65 and converted in Fahrenheit is 97.70.
Example 2:
Input: celsius = 122.11
Output: [395.26000,251.79800]
Explanation: Temperature at 122.11 Celsius converted in Kelvin is 395.26 and converted in Fahrenheit is 251.798.
Code
1
2
3