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

Will rate favorably for executable program... 1.Create a class named Cube that c

ID: 3634549 • Letter: W

Question

Will rate favorably for executable program...

1.Create a class named Cube that contains a private field called depth. This class should be a subclass (extends) of the Square class. The constructor should take three parameters used to initialize the base class and it’s own ‘depth’ member field.
2.Create a method named computeSurfaceArea() that calculates the surface area of the cube. This method should override the parent method. This method should return the surface are of the cube (width x height x depth). You may not directly access the height and width fields of the parent class.
3.Save this class as Cube.java

Explanation / Answer

Please Rate:Thanks

This program will help you

//Square class

public class square {
    private double height;
    private double width;
    public square(){
    }
    public square(double h,double w){
        height=h;
        width=w;
    }
   
    public double SurfaceArea(){
        return height*width;
    }
      
}

------------------------------------------------------------

//Cube class

public class Cube extends square{
    private double depth;
    public Cube(double x,double y,double z){
       height=x;
       width=y;
        depth=z;
    }
    public double computeSurfaceArea(){
        return height*width*depth;
    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote