Java Program For Find Volume of a Box

class Box
{
 double width;
 double height;
 double depth;

 void volume()
 {
 System.out.print(" Volume is ");
 System.out.println(width *height*depth);
 }
}

class BoxDemo
{
public static void main(String args[])
{
Box mybox1= new Box();
Box mybox2= new Box();

mybox1.width=10;
mybox1.height=20;
mybox1.depth=15;

mybox2.width=3;
mybox2.height=6;
mybox2.depth=9;

mybox1.volume();
mybox2.volume();
}
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment