From e5c1c216e6fa4381fc28f76ce661ec418fa72083 Mon Sep 17 00:00:00 2001 From: Ankita Kshatriya <58108015+Ankita909@users.noreply.github.com> Date: Fri, 1 Oct 2021 19:08:50 +0530 Subject: [PATCH] Contructor program A basic java program to calculate the Volume of the box from given dimensions based on Constructor. --- Java/BoxD.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Java/BoxD.java diff --git a/Java/BoxD.java b/Java/BoxD.java new file mode 100644 index 00000000..7fe743a0 --- /dev/null +++ b/Java/BoxD.java @@ -0,0 +1,25 @@ +class Box{ + double length; + double breadth; + double height; + +Box(double l,double b,double h){ + length=l; + breadth=b; + height=h; +} + +//compute and return volume +double volume(){ + return length*breadth*height; +} +} +class BoxD{ + public static void main(String args[]){ + Box a=new Box(3.9,9.8,7.6); + Box b=new Box(4.8,10.8,8.9); + + System.out.println(a.volume()); + System.out.println(b.volume()); + } +} \ No newline at end of file