Search⌘ K

Challenge: Temperature Conversion

Explore how to implement temperature conversion from Fahrenheit to Celsius in Scala. This lesson helps you apply Scala arithmetic operators to solve real-world problems by performing calculations and storing results in variables.

Problem Statement

You are given a variable fahrenheit which stores a temperature in degrees Fahrenheit. You have to create a variable celsius which converts the temperature stored in fahrenheit to degrees Celsius.

To convert temperature from degrees Fahrenheit to degrees Celsius, you first need to subtract the temperature by 32 and then multiply it by 5 divided by 9.

Input

The input is the variable fahrenheit.

fahrenheit has already been declared for you.

Output

The output will be the value assigned to Celsius.

Sample Input

50.0

Sample Output

10.0

Test Yourself

Write your code in the given area. Try the exercise by yourself first, but if you get stuck, the solution has been provided. Good luck!

Scala
// Rewrite celsius
val celsius = "temp"

Let’s go over the solution review in the next lesson.