Question: java programming For this assignment you will create two Java classes each in a separate Java file: 1. The first is the Box class that

java programming
 java programming For this assignment you will create two Java classes
each in a separate Java file: 1. The first is the Box
class that models a heavy "Box" that should be saved in a

For this assignment you will create two Java classes each in a separate Java file: 1. The first is the Box class that models a heavy "Box" that should be saved in a file called Box.java. This class should include the following: a. Four private integer instance variables store the Length, Width, Height, and Weight of the Box. Measurements are in feet and pounds. b. Four public methods (setters) to set the value of each of these parameters: setLength, setWidth, setHeight, and set Weight c. Four public methods (getters) to return the value of each of these parameters: getLength, getWidth, get Height, and get Weight d. Two constructors: > Constructor #1 (default constructor) - has no parameters and initializes each of the Box's instance variable to 0. Constructor #2 - that receive four integer parameters that would initialize the Box object's Length, Width, Height, and Weight. e. A method calculateVolume() which returns the volume (formula: Length*Width"Height) of the Box object as an integer. f. A method calculateDensity which returns the density of the Box (formula: weight/volume) as a double, check for divide by 0. g. A method called toString that returns all information about a box object as a string in the form of: This Box has: Length = xxx, Width - yyy, Height - zzz, Weight = www Volumettt Density =nnn.da 1. The second is the TestBoxes class that should be saved in a file called Text Boxes.java that contains a main() method. This main() method should do the following: 2. Create two different object boxes named b1, and b2 using the second constructor (defined above). The parameters of box bl are: Length - 10, Width - 5, Height 5, and Weight - 2600 The parameters of box b2 are: Length - 15, Width 22. Height -16, and Weight - 1360 b. Create a third box named b3 using the default constructor Then use the set methods (defined above) to assign values for each of the above four parameters as follows: Length 12. Width 14. Height 8, and Weight = 564243 c. Usthg the set methods defined above to change the parameters of object b2 to be as forfows: Length = 40, Width - 11. Height =18, and Weight - 22432/ d. Output all information of each of the three created object boxes (b1,b2, and b3) using the method toString on the screen. Just Compile the Box.java class (you cannot run it, there is no main method) in this class. Compile and run the TestBoxes class. Output: This Box has: Length - 10, Width - 5, Height 5. Weight - 2600 Volume-250 Pensity = 10.4 This Box has: Length - 40, Width - 11, Height - 18, Weight = 224321. Volume-7920 Density 28.32 This Box has: Length - 12. Width - 14. Height & Weight - 564243. Volume - 1344 Density 419.82

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!