interface KeepValues{
final double pie=3.14;
public double area(int r, int h);
}
class Cone implements KeepValues{
double ar,l;
public double area(int r, int h){
l=Math.sqrt((r*r)+(h*h));
System.out.println("Value of slant height"+l);
ar=((r*r)*pie*l);
return ar;
}
}
class Cylinder implements KeepValues{
double ar;
public double area(int r, int h){
ar=(2*(pie*(r*r)*h));
return ar;
}
}
public class DisplayArea{
public static void main(String[] args){
double a,b;
Cone c= new Cone();
a=c.area(3,4);
Cylinder cl=new Cylinder();
b=cl.area(7, 6);
System.out.println("Area of Cone is="+a+" Area of Cylinder is="+b);
}
}
No comments:
Post a Comment