Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java program that finds the heaviest stack of boxes that you can create out of a set of boxes given as input. Read
Write a Java program that finds the heaviest stack of boxes that you can create out of a set of boxes given as input. Read the set of possible boxes from a file, and output the heaviest stack of boxes, from top to bottom, into another file, along with its height and weight of the stack Details Input: The input to the program is a file containing a set of boxes Each line of the input file represents one box with 4 numbers, in the following format: Name Height Width Depth Weight. Depth always 2 width Consider the following input file Alpha 437 34 Fred 5 68 92 Norm 1 4 4 18 The first line is a box named Alpha, of height 4, width 3, depth 7, with weight 34 The second line is a box named Fred, of height 5, width 6, depth 8, with weight 92 The third line is a box named Norm, of height 1, width 4, depth 4, with weight 18 Rules for Box Stacking: A box X may be stacked on top of another box Y if and only if both of the following conditions hold X has a footprint no bigger than Y in either width or depth (so if you stack X on Y, there is no overhang) Box X weighs no more than box Y. Output: Your output should list the boxes in the heaviest stack, from top to bottom, one box per line Algorithm: You must do a dynamic programming algorithm for this problem. You can do either bottom-up or top-down dynamic programming You should also write a short document - not part of the program - that explains how your dynamic programming works. I should be able to look at this document and look at your code, and see that it performs dynamic programming. This should be in the directory with the source code (or the parent directory of that directory)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started