Question: The file KnapsackData 1 . txt and KnapsackData 2 . txt , provided on Canvas. These files are sample input files for the following Knapsack
The file KnapsackDatatxt and KnapsackDatatxt provided on Canvas. These files are sample input files for the following Knapsack Problem that you will solve.
KnapsackDatatxt contains a list of four prospective projects for the upcoming year for a particular
company:
Project
Project
Project
Project
Each line in the file provides three pieces of information:
String: The name of the project;
Integer: The amount of employee labor that will be demanded by the project, measured in work weeks;
Integer: The net profit that the company can expect from engaging in the project, measured in thousands
of dollars.
Your task is to write a program that:
Prompts the user for the number of work weeks available integer;
Prompts the user for the name of the input file string;
Prompts the user for the name of the output file string;
Reads the available projects from the input file;
Solves the corresponding knapsack problem, without repetition of items; and
Writes to the output file a summary of the results, including the expected profit and a list of the best projects for the company to undertake.
Here is a sample session with the program:
Enter the number of available employee work weeks:
Enter the name of input file: KnapsackDatatxt
Enter the name of output file: Outputtxt
Number of projects
Done
For the above example, here is the output that should be written to Outputtxt:
Number of projects available:
Available employee work weeks:
Number of projects chosen:
Total profit:
Project
Project
The file KnapsackDatatxt also provided on Canvas, contains one thousand prospective projects. Your
program should also be able to handle this larger problem as well. The corresponding output file,
Outputtxt is also on Canvas.
With a thousand prospective projects to consider, it will be impossible for your program to finish in a
reasonable amount of time if it uses a bruteforce search that explicitly considers every possible
combination of projects. You are required to use a dynamic programming approach to this problem, as discussed in class. Write in java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
