Monday, February 9, 2009

//Program Name: Cube.java
//Programmer: Miexie D. Tulid
//Description: A class program that allows to manipulate the area and volume of a cube using a constructor with and without a parameter.
//Date: February 04, 2009


public class Cube{

private double cwidth;
private double clength;
private double cheight;





public Cube(double width, double height, double length)
{
this.cwidth=width;
this.cheight=height;
this.clength=length;
}

public Cube()
{

}

private double volume()
{

return (cwidth*clength*cheight);

}


private double area()
{

return (cwidth*clength);

}


public void setDimension(double newwidth, double newheight, double newlength)
{
this.cwidth=newwidth;
this.cheight=newheight;
this.clength=newlength;
}

public String displayCube()
{
return String.format(volume()+" and "+area());

}
}

No comments:

Post a Comment