-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWaterTank.java
More file actions
31 lines (22 loc) · 820 Bytes
/
Copy pathWaterTank.java
File metadata and controls
31 lines (22 loc) · 820 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
import java.util.*;
public class WaterTank {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the radius");
int radius = sc.nextInt();
if(radius <= 0){
System.out.println("Invalid measurement");
return;
}
System.out.println("Enter the height");
int height = sc.nextInt();
if(height <= 0){
System.out.println("Invalid measurements");
return;
}
double volumeOfCylinder = 3.14 * radius * radius * height;
double capacity = 0.75*volumeOfCylinder;
System.out.printf("Total Volume of the tank is %.2f litres%n", volumeOfCylinder);
System.out.printf("Total Capacity %.2f litres%n",capacity);
}
}