-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeometryCalculator.java
More file actions
37 lines (30 loc) · 1.05 KB
/
GeometryCalculator.java
File metadata and controls
37 lines (30 loc) · 1.05 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
import java.io.*;
public class GeometryCalculator {
int square(int a) {
return a * a;
}
int rectangle(int l, int b) {
return l * b;
}
double circle(int r) {
double pi, area;
pi = 3.14;
area = pi * r * r;
return area;
}
public static void main() throws IOException {
GeometryCalculator obj = new GeometryCalculator();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("SIDE OF SQUARE = ");
int a = Integer.parseInt(br.readLine());
System.out.println("AREA = " + obj.square(a));
System.out.println("Length of L = ");
int l = Integer.parseInt(br.readLine());
System.out.println("Length of B = ");
int b = Integer.parseInt(br.readLine());
System.out.println("AREA = " + obj.rectangle(l, b));
System.out.println("Enter the radius of CIRCLE =");
int r = Integer.parseInt(br.readLine());
System.out.println("AREA OF THE CIRCLE = " + obj.circle(r));
}
}