Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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 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
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