-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.java
More file actions
52 lines (52 loc) · 1.16 KB
/
Copy pathinheritance.java
File metadata and controls
52 lines (52 loc) · 1.16 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
import java.util.*;
class Shape{
float length,breadth,radius;
}
class rect extends Shape{
rect(float l,float b)
{
length=l;
breadth=b;
}
float rect_area()
{
return length*breadth;
}
}
class circle extends Shape{
circle(float r)
{
radius=r;
}
float circle_area()
{
return (radius*radius*(float)3.14);
}
}
class square extends Shape{
square(float lg)
{
length=lg;
}
float square_area()
{
return length*length;
}
}
public class area
{
public static void main(String args[])
{Scanner in=new Scanner(System.in);
float lng,br,rs;
System.out.println("Enter length breadth and radius:");
lng=in.nextFloat();
br=in.nextFloat();
rs=in.nextFloat();
rect ob1=new rect(lng,br);
System.out.println("Area of rectangle="+ob1.rect_area());
circle ob2=new circle(rs);
System.out.println("Area of circle="+ob2.circle_area());
square ob3=new square(lng);
System.out.println("Area of square="+ob3.square_area());
}
}