Oct-17-2020, 08:07 PM
I don't see a question, but your answers will be wrong.
You are assuming calculations occur left to right. That is true of things at the same order of precedence, but not everything.
In brief - addition and subtraction at same level
Multiplication and division a level above
Exponentiation a level above that
Parentheses a level above that
So, line 27 will calculate 32*5/9, subtract that from fah and then add 273. Wrong answer. Proper format would be
You are assuming calculations occur left to right. That is true of things at the same order of precedence, but not everything.
In brief - addition and subtraction at same level
Multiplication and division a level above
Exponentiation a level above that
Parentheses a level above that
So, line 27 will calculate 32*5/9, subtract that from fah and then add 273. Wrong answer. Proper format would be
return (fah - 32) * 5/9 + 273.15The same type of error is repeated in lines 24 and 33.