class areaCalc
{
void area(int
l)
{
System.out.println("Area
of square is: "+(l*l));
}
void area(float
r)
{
System.out.println("Area
of circle is: "+(3.14*r*r));
}
void area(int
l,int b)
{
System.out.println("Area
of rectangle is: "+(l*b));
}
void area(float
b,float h)
{
System.out.println("Area
of triangle is: "+(0.5*b*h));
}
}
class poly
{
public static
void main(String args[])
{
areaCalc ac=new
areaCalc();
ac.area(30);
ac.area(10.5f);
ac.area(10,20);
ac.area(5.6f,7.8f);
}
}
OUTPUT: 5A
C:\Program
Files\Java\jdk1.7.0\bin>java poly
Area of square
is: 900
Area of circle
is: 346.185
Area of
rectangle is: 200
Area of triangle
is: 21.84000016212462
No comments:
Post a Comment