Question: 1) Ask the user for the capacity first, then keep getting the items until their total exceeds the capacity. Output the final total, without exceeding
1) Ask the user for the capacity first, then keep getting the items until their total exceeds the capacity. Output the final total, without exceeding the capacity. Enter capacity: 10 Input items: 3 5 1 4 Total: 9
2) After outputting the total, accommodate the final item in the next package and keep going! Infinite loop is OK. Enter capacity: 10 Input items: 3 5 1 4 Total: 9 3 5 Total: 7 ...
3) After outputting the total, accommodate the final item in the next package and keep going! Infinite loop is OK. Loop read item IF it can be accommodated add to total ELSE output current total init total with this item Enter capacity: 10 Input items: 3 5 1 4 Total: 9 3 5 Total: 7 ...
4) Each item weights 1 or 2 or 3 lbs. Capacity of each box is 3 lbs. Given # of items in each weight, determine minimum # of boxes needed. (1, 1, 1) (1, 2, 3) (3, 2, 1) (3, 1, 2) (5, 10, 15) (16, 10, 5) (10, 5, 15)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
