0
Code coach Halloween Candy.
Hi. It takes first input 3. When you calculate it, you see 67,65 on calculator. So the code shows us integer and the answer should be 67. But it returns 66 and I couldn't solve it. What am I missing? Thanks in advance. https://code.sololearn.com/c1gxl3XphW58/?ref=app Edit: I understood that java take the number as integer after every single operation, not at the end. Normally, 200/3+99/100=67.66 --> 67 (as integer) Java makes it this way; 200/3=66.66 --> 66 (as integer) 99/100=0.99 --> 0 (as integer) 66+0=66 That's why not 67. 👆🏻
2 Antworten
0
int chance = (int)
(Math.ceil(2.0*100/houses));
Use this line. Because as you need to take it to nearest integer
0
Thanks, i saw math.ceil on other discussions about this Halloween code but i am trying to solve this way. It should work but isn't working. :)