public static void fillKnapsack(double totalValue, double bagMaxWeight, double itemArray[][], double unitValue[], int itemNumber[], DecimalFormat df){
		double[] originalWeight = {itemArray[1][0], itemArray[1][1], itemArray[1][2], itemArray[1][3]};

		int limit = 0;
		for(int i=0; i<4; i++){
			while((itemArray[1][i]) != 0){
				if(limit<bagMaxWeight){
					totalValue += unitValue[i];
					itemArray[1][i]--;
					limit++;
				}
				else{
					break;//Avoid infinite loop if there is no room left in bag
				}
			}
		}

		//Prints the percentage of items taken by knapsack and the optimal total value it can hold
		for(int y=0; y<4; y++)
			System.out.println("Knapsack took %"+df.format(100*((1-itemArray[1][y]/originalWeight[y])))+" of item " + itemNumber[y]);
		System.out.println("\nTotal value knapsack can hold: $" + df.format(totalValue));
	}