Beginner Level

Implement the method celsiusToFahrenheit that converts Celsius to Fahrenheit.

Convert a Celsius temperature into Fahrenheit using F = C * 9 / 5 + 32. The result can contain a decimal part.

The task is designed to test careful handling of edge cases, not only the most common input.

  • Accept negative, zero, and positive temperatures.
  • Use floating-point arithmetic for the division.
  • Return the converted temperature without unnecessary rounding.
Example 1
Input:
c (double) = 0
Return:
(double) 32
Example 2
Input:
c (double) = 100
Return:
(double) 212
Example 3
Input:
c (double) = -40
Return:
(double) -40
Example 4
Input:
c (double) = 37
Return:
(double) 98.6

Multiply the Celsius value by 9, divide by 5, and add 32. In languages with integer division, force floating-point arithmetic.

Run your code to see the result.