- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVol.java
More file actions
Latest commit
23 lines (20 loc) · 657 Bytes
/
Copy pathVol.java
File metadata and controls
23 lines (20 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
publicclassVol {
doublevolume(doubler) {
doublevol = (4 / 3.0) * (22 / 7.0) * r * r * r;
returnvol;
}
doublevolume(doubleh, doubler) {
doublevol = (22 / 7.0) * r * r * h;
returnvol;
}
doublevolume(doublel, doubleb, doubleh) {
doublevol = l * b * h;
returnvol;
}
publicstaticvoidmain(Stringargs[]) {
Volobj = newVol();
System.out.printf("Sphere Volume = %.3f\n",obj.volume(4));
System.out.printf("Cylinder Volume = %.3f\n",obj.volume(6.2, 4.6));
System.out.printf("Cuboid Volume = %.3f\n",obj.volume(8.5, 4.6, 6.2));
}
}