- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassbox.java
More file actions
Latest commit
57 lines (45 loc) · 1.36 KB
/
Copy pathclassbox.java
File metadata and controls
57 lines (45 loc) · 1.36 KB
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
48
49
50
51
52
53
54
55
56
57
importjava.util.*;
publicclassclassbox {
privateintlength;
privateintbreadth;
privateintheight;
classbox(){
intlength = 0;
intbreadth = 0;
intheight = 0;
}
classbox(intlength, intbreadth, intheight){
this.length = length;
this.breadth = breadth;
this.height = height;
}
classbox(classboxb1){
this.length = b1.length;
this.breadth = b1.breadth;
this.height = b1.height;
}
intgetlength(){
returnlength;
}
intgetbreadth(){
returnbreadth;
}
intgetheight(){
returnheight;
}
longgetvolume(){
return (long) length * breadth * height;
}
publicstaticvoidmain(String[] args) {
Scannersc = newScanner(System.in);
intl = sc.nextInt();
intb = sc.nextInt();
inth = sc.nextInt();
classboxb1 = newclassbox();
System.out.println(b1.getlength() + " " + b1.getbreadth() + " " + b1.getheight() + " " + b1.getvolume());
classboxb2 = newclassbox(l, b, h);
System.out.println(b2.getlength() + " " + b2.getbreadth() + " " + b2.getheight() + " " + b2.getvolume());
classboxb3 = newclassbox(b2);
System.out.println(b3.getlength() + " " + b3.getbreadth() + " " + b3.getheight() + " " + b3.getvolume());
}
}