Why does my code work incorrectly? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why does my code work incorrectly?

https://code.sololearn.com/cjK3zuiVvjSf/?ref=app Tack: Haloween Candy from practice in community

18th Jan 2023, 5:44 PM
Nikolai
4 Answers
+ 5
Nikolai Math.Ceiling(chance);
18th Jan 2023, 5:55 PM
A͢J
A͢J - avatar
+ 1
Nikolai Math.Round(4.3) = 4.0 Math.Ceiling(4.3) = 5.0
18th Jan 2023, 7:40 PM
A͢J
A͢J - avatar
0
Task: You go trick or treating with a friend and all but three of the houses that you visit are giving out candy. One house that you visit is giving out toothbrushes and two houses are giving out dollar bills. Task Given the input of the total number of houses that you visited, what is the percentage chance that one random item pulled from your bag is a dollar bill? Input Format An integer (>=3) representing the total number of houses that you visited. Output Format A percentage value rounded up to the nearest whole number. Sample Input 4 Sample Output 50
18th Jan 2023, 5:44 PM
Nikolai
0
AJ Thank you , now it actually works! But I would like to know what is the real difference between Math methods Ceiling and Round , for me its absolutely same
18th Jan 2023, 6:16 PM
Nikolai