I'm trying to make a small program in Java which converts Fahrenheit to Celsius. It involves deducting 32 and multiplying by 5/9. So I did this.
double Fahrenheit = 100;
double celsius = (Fahrenheit - 32) * (5/9);
System.out.println(celsius);
But for some reason that 5/9 returns zero which ruins it all, even
double s = 5/9;
returns zero and I don't know why. The only way I found I can do it is if I declare everything and do it slowly, step by step.
double x = 5, p = 9, n = (x/p), Fah = 100;
double Cel = Fah - 32;
Cel = Cel*n;
Can anyone tell me why this sort of thing happens, I thought at least declaring it as a double would return a value. And if anyone knows, a way round it.