-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabstract.java
60 lines (52 loc) · 1.27 KB
/
abstract.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
50
51
52
53
54
55
56
57
58
59
60
import java.io.*;
abstract class shape
{
int l,b;
abstract void printArea();
}
class rectangle extends shape
{
void printArea() throws Exception
{
DataInputStream d=new DataInputStream(System.in);
System.out.println("enter the length");
l=Integer.parseInt(d.readLine());
System.out.println("enter the breadth");
b=Integer.parseInt(d.readLine());
System.out.println("AREA OF RECTANGLE="+(l*b));
}
}
class triangle extends shape
{
void printArea1() throws Exception
{
DataInputStream d=new DataInputStream(System.in);
System.out.println("enter the length");
l=Integer.parseInt(d.readLine());
System.out.println("enter the height");
b=Integer.parseInt(d.readLine());
System.out.println("AREA OF TRIANGLE="+(0.5f*l*b));
}
}
class circle extends shape
{
void printArea2() throws Exception
{
DataInputStream d=new DataInputStream(System.in);
System.out.println("enter the radius");
l=Integer.parseInt(d.readLine());
System.out.println("AREA OF CIRCLE="+(3.14f*l*l));
}
}
class m
{
public static void main(String v[]) throws Exception
{
rectangle r=new rectangle();
r.printArea();
triangle t=new triangle();
t.printArea1();
circle c=new circle();
c.printArea2();
}
}