find the area and perimeter of cirlcle,rectangle,square using buffer reader class with inheritance in java
Answers
Answered by
0
class FindRectangleArea
{
public static void main(String arg[])
{
Rectangle rect = new Rectangle(10, 5);
System.out.println("Length = " + rect.length);
System.out.println("Breadth = " + rect.breadth);
System.out.println("Area = " + rect.getArea());
System.out.println("Perimeter = " + rect.getPerimeter());
}
}
class Rectangle
{
double length;
double breadth;
Rectangle(double length, double breadth)
{
this.length = length;
this.breadth = breadth;
}
double getArea()
{
return length * breadth;
}
double getPerimeter()
{
return 2 * (length + breadth);
}
Similar questions