What am I doing wrong on “Halloween Candy” activity? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

What am I doing wrong on “Halloween Candy” activity?

https://code.sololearn.com/cVZoH50bKnI0/?ref=app My code won’t round up correctly!

12th Jun 2020, 7:14 PM
Lord Gannon
Lord Gannon - avatar
1 Antwort
+ 2
You are using type conversion to int - not rounding. If you int a floating point number, only the decimals are cut off. Basically you round towards zero. For proper rounding - and ceiling and flooring - include cmath and use the specific functions from there.
12th Jun 2020, 7:17 PM
HonFu
HonFu - avatar