I think the wording of this challenge is very confusing. They want us to convert Celsius to Fahrenheit. But the answer to the Challenge is not completely correct.
The Challenge:
"To test your learning, you will create a solution “from scratch”. Place your code between the indicated lines and it will be tested against multiple test cases.
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit."
The Answer:
fahrenheit = celsius;
fahrenheit *= 9;
fahrenheit /= 5;
fahrenheit += 32;
The last paragraph where it says “variable fahrenheit already defined” to me states that in this case we are suppose to use the variable fahrenheit and calculate for celsius. However, the equation to calculate for celsius is not F*9, F/5, and +32 (as suggested by the solution above). So, the wording should be switched here to say “celsius is already defined” because the title of the challenge is to convert celsius to fahrenheit and not fahrenheit to celsius.
The answer to this challenge is not completely correct, to me, unless someone can explain that it is correct. Why are we taking the known variable fahrenheit(but it’s suppose to be unknown hence the challenge to convert celsius to fahrenheit) and using the equation, to calculate fahrenheit, to calculate for fahrenheit when we already know what fahrenheit is.
In the previous paragraph, they state how to calculate fahrenheit, “algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32”. So, F = C * 9/5 +32. Therefore, the “algorithm” to calculate celsius is C = F - 32 *5/9.
So if we know what fahrenheit is then shouldn’t we calculate for celsius and not fahrenheit again.
And the solution should say “celsius” instead of fahrenheit because the equation being used is for calculating fahrenheit in the case that celsius is defined.
It should look like this:
fahrenheit = celsius;
celsius *= 9;
celsius /= 5;
celsius += 32;
Answer to convert fahrenheit to celsius:
fahrenheit = celsius;
fahrenheit -= 32;
fahrenheit *= 5;
fahrenheit /= 9;
I understand the concept, but this can really confuse some people such as myself, because logically this does not make sense at all. And if all you care about is getting the correct answer, then what’s the point of all of this.