public static void main(String[] args) { Box mb1 = new Box(); Box mb2 = new Box(); mb1.depth = 10; mb1.width = 20; mb1.height = 15; mb2.depth = 3; mb2.width = 6; mb2.height = 9; System.out.println("Objetosc: " + mb1.volume()); System.out.println("Objetosc: " + mb2.volume()); }
public static void main(String[] args) { Box mb1 = new Box(); Box mb2 = new Box(); mb1.depth = 10; mb1.width = 20; mb1.height = 15; mb2.depth = 3; mb2.width = 6; mb2.height = 9; mb1.volume(); mb2.volume(); }
public static void main(String args[]) { Box myBox1 = new Box(); Box myBox2 = new Box(); double vol; myBox1.width = 10; myBox1.height = 20; myBox1.depth = 15; myBox2.width = 6; myBox2.height = 3; myBox2.depth = 0.5; // print value System.out.println("Volume of Box 1 is: " + myBox1.volume()); System.out.println("Volume of Box 2 is: " + myBox2.volume()); }
public static void main(String[] args) { // TODO Auto-generated method stub Box box1 = new Box(); Box box2 = new Box(); box1.width = 10; box1.height = 10; box1.depth = 10; box2.width = 20; box2.height = 20; box2.depth = 20; box1.volume(); box2.volume(); }
public static void main(String args[]) { Box mybox1 = new Box(); Box mybox2 = new Box(); double vol; // assign values to mybox1's instance variables mybox1.width = 10; mybox1.height = 20; mybox1.depth = 15; /* assign different values to mybox2's instance variables */ mybox2.width = 3; mybox2.height = 6; mybox2.depth = 9; // compute volume of first box vol = mybox1.width * mybox1.height * mybox1.depth; System.out.println("Volume is " + vol); // compute volume of second box vol = mybox2.width * mybox2.height * mybox2.depth; System.out.println("Volume is " + vol); }