-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBox.java
More file actions
47 lines (40 loc) · 928 Bytes
/
Box.java
File metadata and controls
47 lines (40 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package chandana;
public class Box
{
double width;
double height;
double depth;
public Box()
{
width=1.0;
height=1.0;
depth=1.0;
}
public Box(double width,double height,double depth)
{
this.width=width;
this.height=height;
this.depth=depth;
}
public double volume()
{
return width*height*depth;
}
public static void main(String[] args)
{
Box box1=new Box();
System.out.println("Box1 ");
System.out.println("width: "+box1.width);
System.out.println("height : "+box1.height);
System.out.println("depth: "+box1.depth);
System.out.println("Volume: "+box1.volume());
System.out.println();
Box box2=new Box(2,7,9);
System.out.println("Box2 ");
System.out.println("width: "+box2.width);
System.out.println("height : "+box2.height);
System.out.println("depth: "+box2.depth);
System.out.println("Volume: "+box2.volume());
System.out.println();
}
}