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

30th Sep 2021, 4:37 AM
Arun Bhattacharya
Arun Bhattacharya - avatar
1 Respuesta
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)
30th Sep 2021, 5:02 AM
Erlénio.RS
Erlénio.RS - avatar