0
Mistake in Calculation : : Java
I have a math to be solved in Java but it doesn't give me the right answer. https://code.sololearn.com/cVcJ7ZgQ1iQJ/?ref=app
1 Answer
0
It gives an error because you are casting the result(10/100) = 0
How your program is interpreted
>>4825 - (float) 4225*(10/100)
4825 - (float) 4225*0
4825 - 0.0
= 4825.0
To solve this, put one of the values ââin the division as a float:
4825 - (float) 4225*(10/100f) or
4825 - (float) 4225*(10.0/100)