-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxVol.java
More file actions
32 lines (31 loc) · 812 Bytes
/
BoxVol.java
File metadata and controls
32 lines (31 loc) · 812 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
import java.util.*;
public class BoxVol {
public static void main(String[] args) {
System.out.println("Enter length, Breadth and Height: ");
Scanner inp = new Scanner(System.in);
double l = inp.nextDouble();
double b = inp.nextDouble();
double h = inp.nextDouble();
if(l<=0 || b<=0 || h<=0){
System.out.println("Invalid Input");
System.exit(1);
}
Box obj = new Box(l,b,h);
double v = obj.volume();
System.out.println(v + " unit^3");
inp.close();
}
}
class Box{
double l, b, h, vol;
Box(double x, double y, double z)
{
l = x;
b = y;
h = z;
}
double volume(){
double vol = l*b*h;
return vol;
}
}