You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For exercise 3 in chapter 1 we have to half value, but in answer it's not halved.
Take the result from exercise 2, half it, and convert it back to Centigrade. You can use the generated constant variable (e.g. "res0") instead of copying and pasting the value yourself.
Answer
Using parentheses around the subtraction, which needs to occur before the multiplication and division, will give it highest precedence.
scala> 22.5 * 9 / 5 + 32
res0: Double = 72.5
scala> (res0 - 32) * 5 / 9
res1: Double = 22.5
The text was updated successfully, but these errors were encountered:
For exercise 3 in chapter 1 we have to half value, but in answer it's not halved.
Answer
Using parentheses around the subtraction, which needs to occur before the multiplication and division, will give it highest precedence.
scala> 22.5 * 9 / 5 + 32
res0: Double = 72.5
scala> (res0 - 32) * 5 / 9
res1: Double = 22.5
The text was updated successfully, but these errors were encountered: