Volume of a box


class Box1
{
double width;
double length;
double height;
double volume;
public Box1(double w,double l,double h)
{
this.width=w;
this.length=l;
this.height=h;
}
void computeVolume()
{
volume=width*length*height;
}
public double getVolume()
{
return volume;
}
public static void main(String args[])
{
Box1 mybox1=new Box1(10.0,20.0,15.0);
Box1 mybox2=new Box1(10.0,20.0,10.0);
mybox1.computeVolume();
mybox2.computeVolume();
System.out.println("volume is: "+mybox1.getVolume());
System.out.println("volume is: "+mybox2.getVolume());
}
}

Comments

Popular posts from this blog

GL_QUAD_STRIP Example In OpenGl

GL_POLYGON Example In OpenGl