Program:-
interface
shape
{
void read(double x);
void show();
final static double PI=3.14;
}
class
rectangle implements shape
{
double w=5.0,h;
public void read(double x)
{
h=x;
}
public void show()
{
System.out.println("Area
of rectanle is: "+(w*h));
}
}
class
circle implements shape
{
double r;
public void read(double x)
{
r=x;
}
public void show()
{
System.out.println("Area
of Triangle is: "+(PI*r*r));
}
}
class u44
{
public static void main(String
args[])
{
rectangle r = new
rectangle();
r.read(5.7);
r.show();
circle c=new circle();
c.read(6.0);
c.show();
}
}
No comments:
Post a Comment