Halloween Candy code coach problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

7th Jul 2023, 6:53 PM
Blessing Malema
Blessing Malema - avatar
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;
7th Jul 2023, 8:49 PM
SoloProg
SoloProg - avatar
+ 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().
8th Jul 2023, 1:29 AM
Brian
Brian - avatar