Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions volume_example/Cube.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class Cube
{
public static void main(String []args)
{
double s = 0;
s = 5;

Volume obj = new Volume(s);
obj.calcVolume(10);
obj.printThis();
}
}
12 changes: 12 additions & 0 deletions volume_example/Cuboid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class Cuboid
{
public static void main(String []args)
{
double l = 5;
double b = 5;
double h = 5;

Volume obj = new Volume(l, b, h);
obj.printThis();
}
}
34 changes: 34 additions & 0 deletions volume_example/Volume.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
public class Volume
{
double volume = 0;
double length = 0;
double breadth = 0;
double height = 0;
double side = 0;

public Volume(double side)
{
this.side = side;//global side = local side

//volume = this.side * this.side * this.side;
}

public Volume(double length, double breadth, double height)
{
this.length = length;
this.breadth = breadth;
this.height = height;

volume = this.length * this.breadth * this.height;
}

public void Vcalcolume(int s)
{
volume = side*side*side;
}

public void printThis()
{
System.out.println("The volume of the figure is " + volume);
}
}