id/email
password
forgot password
about | help | done | prefs | create account
JavaBat java practice problems

Logic-2 > makeChocolate
prev  |  next  |  chance

We want make a package of goal kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use, assuming we always use big bars before small bars. Return -1 if it can't be done.

makeChocolate(4, 1, 9) → 4
makeChocolate(4, 1, 10) → -1
makeChocolate(4, 1, 7) → 2

...Save, Compile, Run

See Also: Example Code Java help: If Boolean Logic | Strings | While and For Loops | Arrays and Loops


prev  |  next  |  chance   |  JavaBat  >  Logic-2

Forget It! -- delete my code for this problem 224.0

Copyright Nick Parlante 2006-09 - privacy