Question: I need the C++ code for this problem: -A shipping container can hold at most 1000 pounds. You can pack as many items into the
I need the C++ code for this problem:
-A shipping container can hold at most 1000 pounds. You can pack as many items into the container as long as the total weight is <= 1000 pounds.
-What you would like to do is pack your items in as few shipping containers as possible to minimize your shipping costs.
Consider the following strategy:
1. Worst-Fit. Take the items in order they are listed. If the item won't fit in any current shipping container then get a new shipping container and put the item in it. Otherwise, find the container with the mostremaining space and put the item in it. For example, this algorithm would put the items with weights 700,800,200,150,150 into three bins: [700, 200] [800, 150] [150].
ShippingContainer class: To get started on this problem, write a ShippingContainer class in C++. The class should have:
1. A method to add an item (i.e. a weight) to the shipping container, not to exceed total of 1000.
2. Some way to store the individual weights of all items in the container (array)
3. A method to output all the weights (e.g. 700, 200) along with the total weight (900) and the remaining capacity (100).
4. A method that returns the remaining capacity (e.g. 100 if there are two items of weights 700 and 200).
5. A method that returns the total weight.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
