-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_44.java
More file actions
47 lines (47 loc) · 1.07 KB
/
Main_44.java
File metadata and controls
47 lines (47 loc) · 1.07 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
class Cylinder{
private int radius, height;
float pi=3.14f;
public void setHeight(int h){
height=h;
}
public int getHeight(){
return height;
}
public void setRadius(int r){
radius=r;
}
public int getRadius(){
return radius;
}
public float volume(){
float vol=pi*radius*radius*height;
return vol;
}
}
class Rectangle{
private int length, breadth;
public Rectangle(){
length=4;
breadth=5;
}
public int getLength(){
return length;
}
public int getBreadth(){
return breadth;
}
}
public class Main_44 {
public static void main(String[] args) {
Cylinder cy=new Cylinder();
cy.setRadius(5);
cy.setHeight(16);
int h=cy.getHeight();
System.out.println(h);
System.out.println(cy.getRadius());
System.out.println("Volume: "+cy.volume());
Rectangle r= new Rectangle();
System.out.println("Length: "+r.getLength());
System.out.println("Breadth: "+r.getBreadth());
}
}