-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAreal.java
49 lines (41 loc) · 979 Bytes
/
Areal.java
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
abstract class Shape{
public int x,y;
abstract double Area();
}
class Rectangle extends Shape{
public Rectangle(int x,int y){
this.x=x;
this.y=y;
}
public double Area(){
return (x*y);
}
}
class Triangle extends Shape{
public Triangle(int x,int y){
this.x=x;
this.y=y;
}
public double Area(){
return((x*y)/2);
}
}
class Circle extends Shape{
public Circle(int x){
this.x=x;
}
public double Area()
{
return ((1.5707963267948*(x*x)));
}
}
public class Areal{
public static void main(String[]args){
Rectangle r= new Rectangle(4, 5);
System.out.println(r.Area());
Triangle t= new Triangle(4,5);
System.out.println(t.Area());
Circle c= new Circle(5);
System.out.println(c.Area());
}
}