Exercise · Variables and types · lesson 8 of 9
Exercise: Fahrenheit
Write a function function toFahrenheit(c) that converts the temperature c from degrees Celsius to degrees Fahrenheit by the formula F = C × 1.8 + 32.
toFahrenheit(100)→212toFahrenheit(-40)→-40toFahrenheit(36.6)→97.88
Constraints: c is a number, whole or fractional, not below absolute zero, -273.15; the result is compared with the expected one to within 0.000000001. The tests write it as Math.abs(got - 212) < 1e-9: 1e-9 is 0.000000001, Math.abs drops the sign of the difference, and < means "less than".
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.