-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathCalculatingVolume.java
44 lines (38 loc) · 1.05 KB
/
CalculatingVolume.java
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
class Calculate{
public static Scanner scan = new Scanner(System.in);
Output output = new Output();
public static int getINTVal() throws IOException{
int n = scan.nextInt();
if(n<=0)
throw new NumberFormatException("All the values must be positive");
return n;
}
public static double getDoubleVal() throws IOException{
double n = scan.nextDouble();
if(n<=0)
throw new NumberFormatException("All the values must be positive");
return n;
}
public static Volume get_Vol(){
return new Volume();
}
}
class Volume{
public static double main(int a){
return a*a*a;
}
public static double main(int l,int b,int h){
return l*b*h;
}
public static double main(double r){
return (2*Math.PI*r*r*r)/3;
}
public static double main(double r,double h){
return Math.PI*r*r*h;
}
}
class Output{
public static void display(double v){
System.out.println(String.format("%.3f",v));
}
}