Question: (1) Write a class called Box. Each object of type Box represents a cardboard box. The class Box has the following instance variables of type

 (1) Write a class called Box. Each object of type Box

(1) Write a class called Box. Each object of type Box represents a cardboard box. The class Box has the following instance variables of type int: width, height, and length. The class has two constructors: one without parameters that creates a box with width-1, height-1, and length-1, and another one, which has a parameter corresponding to each instance variable. There are also getter and setter methods for each instance variable, and two other methods: getTotalArea0, which returns the total surface area of all sides of the box, and getVolume0, which returns the volume of the box. (2) Write an application class that contains the mainO method. In the mainO method create two objects of class Box- one with the constructor with no parameters and another one with the constructor with three parameters. Then print the total surface area and the volume of each box (using the corresponding methods). Then double the width of the first box and the height of the second one using the corresponding getter and setter methods, and print again their total surface area and volume

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!