I am writing a very simple Fahrenheit to Celsius conversion program that takes a named constant and converts it to Celsius via a simple calculation of (constant - 32) * (5/9)
for whatever reason whenever I run this program it returns 0.0 for Celcius. The math checks out in real life, and the answer is 100, but for whatever reason I keep getting 0.0 from the program. Here's the code:
final double BOILING_IN_F = 212; // Boiling temperature
double fToC; // Temperature Celsius
fToC = (BOILING_IN_F - 32) * (5/9);
output = BOILING_IN_F + " in Fahrenheit is " + fToC + " in Celsius.";
System.out.println(output);
I know that when dividing integers, any fractional number will be returned as a whole, which is why I changed my variables to double. Even still, it returns 0. I also tried using float as my data type and switching around the calculation while adding (irrelevant) parentheses.