-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSarea.java
More file actions
49 lines (49 loc) · 778 Bytes
/
Sarea.java
File metadata and controls
49 lines (49 loc) · 778 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class Shape
{
int x;
int y;
void getData(int x,int y)
{
this.x=x;
this.y=y;
}
void Area()
{
}
}
class Rectangle extends Shape
{
void Area()
{
System.out.println("Area of Rectangle : "+x*y);
}
}
class Triangle extends Shape
{
void Area()
{
System.out.println("Area of Triangle : "+0.5*x*y);
}
}
class circle extends Shape
{
void Area()
{
System.out.println("Area of Circle : "+3.14*x*x);
}
}
class Sarea
{
public static void main(String args[])
{
Rectangle R = new Rectangle();
R.getData(10,20);
R.Area();
Triangle t = new Triangle();
t.getData(10,20);
t.Area();
circle c = new circle();
c.getData(10,0);
c.Area();
}
}