Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NOTE: The completed code must pass in the following compiler. Please make absolu

ID: 3780298 • Letter: N

Question

NOTE: The completed code must pass in the following compiler. Please make absolutely sure it does before posting: http://codecheck.it/codecheck/files?repo=jfe1cc&problem=ch07/c07_exp_7_111

PLEASE also make sure of the following:
-Post this as text, not as an image.
-Avoid making alterations to the original code unless necessary.
-Post the passing output- from the this compiler specifically- as evidence this code was accepted and passed.

~

A box is a three-dimensional object with width, height, and depth.

(image in link above)

Complete the following code:

The following class is used to check your work:

Explanation / Answer

BoxTester.java


public class BoxTester
{
public static void main(String[] args)
{
Box myBox = new Box(10, 10, 10);
System.out.println(myBox.volume());
System.out.println("Expected: 1000");
System.out.println(myBox.surfaceArea());
System.out.println("Expected: 600");
myBox = new Box(10, 20, 30);
System.out.println(myBox.volume());
System.out.println("Expected: 6000");
System.out.println(myBox.surfaceArea());
System.out.println("Expected: 2200");
}
}

Box.java


public class Box
{
private double height;
private double width;
private double depth;

/**
Constructs a box with a given side length.
@param sideLength the length of each side
*/   
public Box(double h, double w, double d)
{
// your work here
   height = h;
   width = w;
   depth = d;
}

/**
Gets the volume of this box.
@return the volume
*/
public double volume()
{
// your work here
   return height * width * depth;
}

/**
Gets the surface area of this box.
@return the surface area
*/
public double surfaceArea()
{
// your work here
   return 2 * (height * width + width*depth + depth* height);
}
}

Output:

1000.0
Expected: 1000
600.0
Expected: 600
6000.0
Expected: 6000
2200.0
Expected: 2200