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

Will rate favorably.These are the parameters for the program. Create a class cal

ID: 3635328 • Letter: W

Question

Will rate favorably.These are the parameters for the program. Create a class called Test that instantiates a square and a cube and then displays the surface area of each one. The display code should be in this class. There should be no display code in the Square or Cube class methods.

public class Test
{
public static void main(String[] args)
{
square s=new square(5.0,5.0);
System.out.println("Surface Area of square "+s.SurfaceArea());
Cube c=new Cube(3.0,4.0,5.0);
System.out.println("Surface Area of cube "+c.computeSurfaceArea());
}

}

Explanation / Answer

{
private int height;
private int width; public Square (int x,int y) {
    height = x; width = y ;
   } public int SurfaceArea()    {
   return height*width;    } public int getHeight() { return height;
} public int getWidth() {
return width; }} ------------------------------------------------------

   public class Cube extends Square{ private int depth; public Cube (int x, int y, int z)
   { super(x,y);
depth =z; } public int computeSurfaceArea()
      { return getHeight() * getWidth() * 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