-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex82.java
More file actions
49 lines (45 loc) · 695 Bytes
/
ex82.java
File metadata and controls
49 lines (45 loc) · 695 Bytes
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
package eight;
interface Shape{
double size();
}
class rectangle{
int a;
int b;
public rectangle(int a,int b){
this.a=a;
this.b=b;
}
public double size(){
return a*b;
}
}
class circle{
int a;
public circle(int a){
this.a=a;
}
public double size(){
return a*Math.PI*a;
}
}
class cylinder{
int a;
int h;
public cylinder(int a,int h){
this.a=a;
this.h=h;
}
public double size(){
return a*Math.PI*a*h;
}
}
public class ex82 {
public static void main(String[] args) {
rectangle a=new rectangle(1,2);
circle b=new circle(3);
cylinder c=new cylinder(3,6);
System.out.println(a.size());
System.out.println(b.size());
System.out.println(c.size());
}
}