-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_52.java
More file actions
55 lines (53 loc) · 1.33 KB
/
Main_52.java
File metadata and controls
55 lines (53 loc) · 1.33 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
class Circle1 {
public int radius;
Circle1(int a) {
System.out.println("circle");
this.radius = a;
}
public double area() {
return Math.PI * this.radius * this.radius;
}
}
class Cylinder3 extends Circle1{
public int height;
Cylinder3(int a, int b){
super(a);
System.out.println("cylinder");
this.height=b;
}
public double volume(){
return Math.PI*this.radius*this.radius*this.height;
}
}
class Rectangle1{
public int length, breadth;
Rectangle1(int l, int b){
this.length=l;
this.breadth=b;
}
public int area(){
return length*breadth;
}
}
class Cuboid extends Rectangle1{
public int height;
Cuboid(int l, int b, int h){
super(l, b);
this.height=h;
}
public float volume(){
return area()*height;
}
}
public class Main_52 {
public static void main(String[] args) {
Circle1 c=new Circle1(7);
System.out.println("area of circle: "+c.area());
Cylinder3 cy=new Cylinder3(7, 4);
System.out.println("volume of cylinder: "+cy.volume());
Rectangle1 r=new Rectangle1(5, 7);
System.out.println("area of rectanger: "+r.area());
Cuboid cb=new Cuboid(5, 6, 6);
System.out.println("volume of cuboid: "+cb.volume());
}
}