-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathShapesArea.java
More file actions
80 lines (73 loc) · 1.1 KB
/
ShapesArea.java
File metadata and controls
80 lines (73 loc) · 1.1 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
interface Area
{
double pi=3.14;
double cal_Area();
}
interface Display extends Area
{
void display_Area();
}
class Rectangle implements Display
{
double x,y;
Rectangle(double a,double b)
{
x=a;
y=b;
}
public double cal_Area()
{
return x*y;
}
public void display_Area()
{
System.out.println("Area of Rectangle is :"+cal_Area());
}
}
class Circle implements Display
{
double radius;
Circle(double r)
{
radius=r;
}
public double cal_Area()
{
return (pi*radius*radius);
}
public void display_Area()
{
System.out.println("Area of Circle is :"+cal_Area());
}
}
class Square implements Display
{
double x;
Square(double a)
{
x=a;
}
public double cal_Area()
{
return (x*x);
}
public void display_Area()
{
System.out.println("Area of Square is :"+cal_Area());
}
}
class ShapesArea
{
public static void main(String s[])
{
Rectangle r = new Rectangle(5,6);
r.cal_Area();
r.display_Area();
Circle c = new Circle(10);
c.cal_Area();
c.display_Area();
Square sq = new Square(5);
sq.cal_Area();
sq.display_Area();
}
}