0
Halloween Candy code coach problem
My code passes the first two test cases and does not pass the others, I can't identify the problem at hand. Could someone please help me out. https://code.sololearn.com/c52MliuGbF31/?ref=app
2 Answers
+ 3
double dollarChance = 0;
// It rounds the value to the nearest integer which is not less than the given value.
if (housesVisited >= 3) dollarChance = ceil((float)2/housesVisited*100);
cout << dollarChance;
+ 3
the kid next door, don't round down. Take note that the requirement for rounding is to round up. That means any amount above the whole number gets pushed up to the next whole number, not only those that are +0.5 above. Use the untruncated float value (don't cast to int), don't add 0.5, and do pass it to the ceil() function instead of round().