Problem of the Day
Friday, September 18, 2026
Problem:
The formula for determining the temperature in degrees Celsius based on a given value in degrees Fahrenheit is

Which of the following instructions, given the double value F, correctly performs that calculation?
double C = 5/9 * F - 32;double C = (5/9) * (F - 32);double C = double(5/9) * (F - 32);double C = 5.0/9 * (F - 32);
The correct answer is d.
When performing division, Java will do an integer division if the operands (5 and 9 in this case) are integers, and 5/9 would be calculated as 0 (9 goes into 5 zero times with a remainder of 5). Answer (c) tries to convert that result to a double value, but not until after the 0 has already been calculated. Answer (d) gets around this issue by specifying that one of the values in the division is a double. Java then performs a division with a double result, which is what we need to successfully perform the conversion.