-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathareaCircleSquareRectangle.java
More file actions
59 lines (54 loc) · 1.2 KB
/
areaCircleSquareRectangle.java
File metadata and controls
59 lines (54 loc) · 1.2 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
public class Main
{
public static void main(String[] args)
{
Rectangle obj = new Rectangle();
// Calling the function
obj.Area(30, 20);
obj.Area(12.5, 4.5);
Circle obj1 = new Circle();
// Calling the function
obj1.Area(3);
obj1.Area(5.5);
Square obj2 = new Square();
// Calling the function
obj2.Area(20);
obj2.Area(5.2);
}
}
class Square
{
void Area(double side)
{
System.out.println("Area of the Square: "+ side * side);
}
void Area(float side)
{
System.out.println("Area of the Square: "+ side * side);
}
}
class Circle
{
static final double PI = Math.PI;
void Area(double r)
{
double A = PI * r * r;
System.out.println("The area of the circle is :" + A);
}
void Area(float r)
{
double A = PI * r * r;
System.out.println("The area of the circle is :" + A);
}
}
class Rectangle
{
void Area(double l, double b)
{
System.out.println("Area of the rectangle: " + l * b);
}
void Area(int l, int b)
{
System.out.println("Area of the rectangle: " + l * b);
}
}