0

Paint Costs Code Coach, Why does this work?[SOLVED]

In my first program the variable "total" was an "int" and it failed tests 3 and 4. On changing it to "double", for some reason it passed all of the tests. My question is why? What difference did it make on changing the data type? My both tries: https://code.sololearn.com/cQzrf8NChi8G/?ref=app https://code.sololearn.com/cVIZLukuS9Zz/?ref=app

23rd Mar 2022, 2:09 PM
Bhaveshsingh Pawar
Bhaveshsingh Pawar - avatar
2 Respuestas
+ 6
Dividing an integer by an integer results in an integer. Check, this will give the desired result: int total = 40+(paintsNo*5); double tax = 10.0*total/100; System.out.println( Math.round(total+tax) );
23rd Mar 2022, 2:28 PM
Solo
Solo - avatar
+ 2
Solo thank you
23rd Mar 2022, 2:34 PM
Bhaveshsingh Pawar
Bhaveshsingh Pawar - avatar