id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > jan8_2016_APSLHLpidgenhole
prev  |  next  |  chance

Write a method that returns how much room remains in the last bin that is used. Bins are used in the order of their numbers. The parameter 'total' contains the total number of items to be placed. Begin placing items into bin1. If all of the items can be placed in bin1, return the amount of space remaining in bin1 (possibly 0). However, if not all of the items in 'total' fit in bin1, first fill bin1, then continue placing items in bin2. Continue in this process until all items from 'total' are placed in as many bins as needed. Return the amount of space remaining in the last bin that needs to be used. However, if the 'total' of items needed to be placed is greater than the total space available in ALL of the bins combined, return -1 as an error code.


jan8_2016_APSLHLpidgenhole(456, 30, 50, 400) → 56
jan8_2016_APSLHLpidgenhole(456, 30, 50, 460) → 26
jan8_2016_APSLHLpidgenhole(5, 5, 5, 15) → 0

...Save, Compile, Run (ctrl-enter)

public int jan8_2016_APSLHLpidgenhole(int bin1, int bin2, int bin3, int total) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 230

Copyright Nick Parlante 2017 - privacy