Answered step by step
Verified Expert Solution
Question
1 Approved Answer
undefined You must submit both Java files mentioned below along with the output as text files. For this assignment you will create two Java classes
undefined
You must submit both Java files mentioned below along with the output as text files. For this assignment you will create two Java classes each in a separate Java file: 1. The first is the Box class that madels 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 Wright of the Ros, Measurements are in fact and pounds. b. Four problic methods (setters) to set the value of each of these parameters: setLength, setWidth, settleight, and se Weight. c. Four public methods (gullers) to return the value of each of these parameters: getLength, get Width, Height, and get Weight d. Two constructors Constructor #1 (default constructor) - has to parameters and initializes cach of the Box's instance variable to 0. > Constructor 2 that receive four integer parameters that would initialize the Box ubject's Length, Width, Height, and Wergirl C Amethod calculate Volumet) which returns the volume (formula: Length"Widtb Height) of the Bax ohject as an integer, . I. A method calculateDensity) which returns the density of the Box (formula weight/vnhomes as a double check for divide by O. 8. A method called toString() that returns all information about a box ubject as a string in the form of This Buxhan Length = xxx, Width = yyy, Height = xxx, Weight = www Vohimette Density = nnn.de 2/3 1. The second is the TestBoxes class that should be saved in a file called TextBoxes.java that contains a main) method. This main) method should do the following: i. Create two different object buses named bl, and b2 using the second constructor defined above) The parameters of box blare: Lengk = 10, Width =5, Heighr =5, and Weight = 2600 The parameters of hox h2 are: Lewgrk 15. Width 22. Height 16, and Weight 7360 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 foar parameters as follows Length = 12. Width=14. Weight =8, and Weight=564243 e. Using the set methods defined above to change the parameters of object b2 to be as follows: Lengrik = 40. Width = 11 Height =1&, and Weight = 224321 d. Output all information of each of the three created object boxes (bl, 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 Test Boxes class. Output: This Box has: 1. The second is the TestBoxes class that should be saved in a file called TextBoxes.java that contains a main() method. This main() method should do the following: a. Create two different object hoxes named bl, and h2 using the second constructor (defined above) The parameters of box blare: Langk-10, Width 5, Heigh5, and Weighr - 2600 The parameters of box h2 are: Lenel = 15, Width = 22. Height = 16, and Weight = 7300 b. Create a third box named 3 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, Wideh=14. Heiglu = 8, and Weight=564243 c. Using the set methods defined above to change the parameters of object b2 to be as follows Length = 40. Width = 17, Height = 18, and Weigle = 224321 d. Output all information of each of the three created object boxes [h1, 62, and b.3) 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 Density = 10.4 This Box basi Length = 40, Width = 11, Heighi -18, Weight = 224321. Volume 7920 Density = 28.32 This Bex lasi Length - 12, Width - 14. Height & Weight - 56424.3. Volume=1.544 Density = 419.82 3/3Step 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