Write a program in java using constuctor
Write a program in java using constuctor
class Box
{
double length,hight,depth;
Box (double l,double h,double d)
{
length=l; hight=h; depth=d;
}
double volume()
{
return(length*hight*depth);
}
}
class BoxDemo2
{
public static void main(String []args)
{
double ans;
Box b1=new Box(2.0,3.8,4.5);
ans=b1.volume ();
System.out.println("volume of box is" + ans);
}
}
class Box
{
double length,hight,depth;
Box (double l,double h,double d)
{
length=l; hight=h; depth=d;
}
double volume()
{
return(length*hight*depth);
}
}
class BoxDemo2
{
public static void main(String []args)
{
double ans;
Box b1=new Box(2.0,3.8,4.5);
ans=b1.volume ();
System.out.println("volume of box is" + ans);
}
}
Comments
Post a Comment