-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS5.java
More file actions
74 lines (56 loc) · 1.18 KB
/
OOPS5.java
File metadata and controls
74 lines (56 loc) · 1.18 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class cylinder{
private int radius;
private int height;
public cylinder(int r,int h) {
this.radius=r;
this.height =h;
}
public void setRadius(int n) {
radius=n;
//return n;
}
public int getRadius()
{
return radius;
}
public void setHeight(int n) {
this.height=n;
//return n;
}
public int getHeight() {
return height;
}
public double getsurfaceArea() {
return 2*3.14*radius*(height+radius);//Math.PI can also be used
}
public double getVolume() {
return 3.14 *radius *radius*height;
}
}
class Rectangle{
private int length;
private int breadth;
public Rectangle(int r,int h) {
this.length=r;
this.breadth =h;
}
public Rectangle() {
this.length=4;
this.breadth =5;
}
}
public class OOPS5 {
public static void main(String[] args) {
cylinder k1=new cylinder(10,20);
//Problem 1
//k1.setRadius(9);
System.out.println(k1.getRadius());
//k1.setHeight(12);
System.out.println(k1.getHeight());
//Problem 2
k1.getsurfaceArea();
System.out.println(k1.getsurfaceArea());
k1.getVolume();
System.out.println(k1.getVolume());
}
}