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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started