class Bx
{
double width;
double height;
double depth;
Bx(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
double volume() {
return width * height * depth;
}
}
class BxDemo7 {
public static void main(String args[]) {
Bx mybox1 = new Bx(4, 7, 20);
Bx mybox2 = new Bx(8, 6, 30);
double ad;
ad = mybox1.volume();
System.out.println("Volume is " + ad);
ad = mybox2.volume();
System.out.println("Volume is " + ad);
}
}
{
double width;
double height;
double depth;
Bx(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
double volume() {
return width * height * depth;
}
}
class BxDemo7 {
public static void main(String args[]) {
Bx mybox1 = new Bx(4, 7, 20);
Bx mybox2 = new Bx(8, 6, 30);
double ad;
ad = mybox1.volume();
System.out.println("Volume is " + ad);
ad = mybox2.volume();
System.out.println("Volume is " + ad);
}
}
No comments:
Post a Comment