write a java program to calculate the area of a rectangle, a square and a circle. create an interface named 'shape' with three abstract methods namely 'rectangle area' taking two parameters, 'squarearea' and 'circlearea' taking one parameter each. the parameters of 'rectangle area' are its length and breadth, that of 'squarearea' is its side and that of 'circlearea' is its radius. now create a class 'area' containing all the three methods 'rectanglearea', 'squarearea' and 'circlearea' for printing the area of rectangle, square and circle respectively. create an object of class 'area' and call all the three methods.
Answers
class FindLargestShape
{
public static void main(String arg[])
{
Rectangle r = new Rectangle(10, 4);
Square s = new Square(7);
Circle c = new Circle(3.5);
System.out.println("Rectangle Area : " + r.getArea());
System.out.println("Square Area : " + s.getArea());
System.out.println("Circle Area : " + c.getArea());
System.out.println();
if ((r.getArea() > c.getArea()) && (r.getArea() > s.getArea()))
{
System.out.println("Rectangle has the largest area.");
}
else if( s.getArea() > c.getArea() )
{
System.out.println("Square has the largest area.");
}
else
{
System.out.println("Circle has the largest area.");
}
}
}
class Rectangle
{
double length;
double breadth;
Rectangle(double length, double breadth)
{
this.length = length;
this.breadth = breadth;
}
double getArea()
{
return length * breadth;
}
}
class Square
{
double side;
Square(double side)
{
this.side = side;
}
double getArea()
{
return side * side;
}
}
class Circle
{
double radius;
Circle(double radius)
{
this.radius = radius;
}
double getArea()
{
return (22.0/7.0) * radius * radius;
}
}
Please Mark as brainlist if you are satisfied
Answer:
enter length and breadth of the triangle