Advertisement
advictoriam

Untitled

Jan 31st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. public class Box
  2. {
  3.    private double height;
  4.    private double width;
  5.    private double depth;
  6.  
  7.    /**
  8.       Constructs a box with a given side length.
  9.       @param sideLength the length of each side
  10.    */  
  11.    public Box(double h, double w, double d)
  12.    {
  13.       height = h;
  14.       width = w;
  15.       depth = d;
  16.    }
  17.  
  18.    /**
  19.       Gets the volume of this box.
  20.       @return the volume
  21.    */
  22.    public double volume()
  23.    {
  24.       return height * width * depth;
  25.    }
  26.    
  27.    /**
  28.       Gets the surface area of this box.
  29.       @return the surface area
  30.    */
  31.    public double surfaceArea()
  32.    {
  33.       return 2*(height*width)+2*(height*depth)+2*(width*depth);
  34.    }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement