$ g++ FractionalKnapsack.cpp $ a.out Enter number of objects: 3 Enter the weight of the knapsack: 50 10 60 20 100 30 120 Added object 1 Weight: 10 Profit: 60 completely in the bag, Space left: 40 Added object 2 Weight: 20 Profit: 100 completely in the bag, Space left: 20 Added object 3 Weight: 20 Profit: 80 partially in the bag, Space left: 0 Weight added is: 20 Bags filled with objects worth: 240