Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your program should read the data from a text file ( Inknapsack.txt )of an unkno

ID: 3622926 • Letter: Y

Question


Your program should read the data from a text file (Inknapsack.txt)of an unknown length that corresponds to items weights. The program would then prompt the user for the weight limits for the knapsack and then prints out the best solution to the problem on the screen and to an output file(outknapsack.txt) as well. a typical input file would have the following data (the first line contains only the number of lines in the input file):
13
3 8 50
7 12 15
4 9 12....

IT SHOULD RUN LIKE THIS

Enter the weight limit of your knapsack:
15

The output of your program would be something like this:

I have found the solution that maximizes your knapsack value when you pick the following items:

6 15
3 18
5 22

The total value of your knapsack is: 55 $. The total weight is 14kg.

Explanation / Answer

Dear... #include #include #define max 15 int w[max],i,j,p[max]; int n,m; float unit[max]; int y[max],x[max],fp=-1,fw; void get() { printf(“ Enter total number of items: “); scanf(“%d”,&n); printf(“ Enter the Maximum capacity of the Sack: “); scanf(“%d”,&m); for(i=0;i