import java.util.*; public class BinPacking { /* ----------------------------------------------------------- SolveBP(k1, s1, k2, s2, k3, s3, res, Cap): returns the min # bins needed to pack: k1 items of size s1 k2 items of size s2 k3 items of size s3 using bins of capacity Cap when the current bin has a residual capacity of "res" ----------------------------------------------------------- */ public static int solveBP(int k1, int s1, int k2, int s2, int k3, int s3, int res, int Cap) { // Write you (recursive) solution here } public static void main(String[] args) { int n1, n2, n3; int s1, s2, s3; int Cap; int out; Scanner in = new Scanner(System.in); System.out.print("Size of item 1 = "); s1 = in.nextInt(); System.out.print("Number of item 1 = "); n1 = in.nextInt(); System.out.print("Size of item 2 = "); s2 = in.nextInt(); System.out.print("Number of item 2 = "); n2 = in.nextInt(); System.out.print("Size of item 3 = "); s3 = in.nextInt(); System.out.print("Number of item 3 = "); n3 = in.nextInt(); System.out.println(); System.out.print("Capacity of the bin = "); Cap = in.nextInt(); if ( s1 > Cap || s2 > Cap || s3 > Cap ) { System.out.println("Input error: some item's size is too large for bin"); System.exit(1); } out = solveBP(n1, s1, n2, s2, n3, s3, Cap, Cap); System.out.println("Min # bins needed = " + out); } }