Box.java
Class Box {Double Width; Double Height; Double Depth;
BoxDemo.java
/ * A Program That Uses The Box Class. Call this file boxdemo.java * /// this class declares an Object of type box.class boxdemo {public static void main (String [] args) {box mybox = new box ( ); double vol; // assign values to mybox's instance variable mybox.width = 10; mybox.height = 20; mybox.depth = 15; // compute volume of box vol = mybox.width * mybox.height * mybox.depth System.out.println ("Volume IS" Vol);}}
BoxDemo2.java
// This program declares two Box objects.class BoxDemo2 {public static void main (String [] args) {Box mybox1 = new Box (); Box mybox2 = new Box (); double vol; // assign valuse to mybox1's instance variable MyBox1.Width = 10; mybox1.height = 20; mybox1.depth = 15; / * * assign diffancy Values to mybox2's instance variable * / mybox2.width = 3; mybox2.de = 6; myBox2.depth = 9; // computer volume of first box vol = mybox1.width * mybox1.height * mybox1.depth; System.out.println ( "Volume is" vol); // computer volume of second box vol = mybox2.width * mybox2.height * Mybox2.depth; system.out.println ("Volume is" Vol);}}