Solution Review: Temperature Conversion

In the following lesson, we will go over the solution for the challenge: Temperature Conversion.

We'll cover the following

Task

In this challenge, you were provided with a variable that stored the temperature in degrees Fahrenheit and you were asked to convert it to degrees Celsius.

Solution

The formula used for converting temperatures from degrees Fahrenheit to Celsius is:

(fahrenheit - 32) * (5D / 9D)

All you have to do is rewrite celsius and assign it the conversion formula above.

val celsius = (fahrenheit - 32) * (5D / 9D)

You can find the complete solution below:

You were required to write the code on line 2.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy