import java.lang.*;
interface Circle
{
final static float pi = 3.14f;
public float compute(float r);
}
class Area implements Circle
{
public float compute(float r)
{
return ( pi * r * r);
}
}
class Circumference implements Circle
{
public float compute(float r)
{
return(2 * pi * r);
}
}
class InterTest
{
public static void main(String args[])
{
Area obArea= new Area();
Circumference obCircum= new Circumference();
Circle InObj;
InObj=obArea;
System.out.println("Area of Cirle=" +InObj.compute(5));
InObj=obCircum;
System.out.format("Circumference of
Circle="+InObj.compute(10));
}
}
interface Circle
{
final static float pi = 3.14f;
public float compute(float r);
}
class Area implements Circle
{
public float compute(float r)
{
return ( pi * r * r);
}
}
class Circumference implements Circle
{
public float compute(float r)
{
return(2 * pi * r);
}
}
class InterTest
{
public static void main(String args[])
{
Area obArea= new Area();
Circumference obCircum= new Circumference();
Circle InObj;
InObj=obArea;
System.out.println("Area of Cirle=" +InObj.compute(5));
InObj=obCircum;
System.out.format("Circumference of
Circle="+InObj.compute(10));
}
}
No comments :
Post a Comment