Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please I need help with this java problem Define a Polygon interface that has me

ID: 3784324 • Letter: P

Question

Please I need help with this java problem

Define a Polygon interface that has methods area() and perimeter(). Then implement classes for Triangle, Quadrilateral, Pentagon, Hexagon, and Octagon, which implement this interface, with the obvious meanings for the area() and perimeter() methods.

Also implement classes, IsoscelesTriangle, EquilateralTriangle, Rectangle, and Square, which have the appropriate inheritance relationships. Finally, write a simple user interface, which allows users to create polygons of the various types, input their geometric dimensions, and then output their area and perimeter. also allow users to input polygons by specifying their vertex coordinates and be able to test if two such polygons are similar.

Explanation / Answer

The following code illustrates inheritence

[Polygon] --------> [Quadilateral] --------> [Square, Rectangle]

public abstract Polygon {
private int N; // number of points in the polygon
   private double perimeter;
   private double area;
public double perimeter();
public double area();
}

public class Quadilateral extends Polygon {
   public void Quadilateral() {
       N=4;
   }
}

public class Square extends Quadilateral {
   public void Square() {
       System.out.print("Please enter side of square: ");
       int side = scanner.nextInt();
   }
   public double perimeter() {
       double perimter = 4*side;
       return perimeter;
   }
   public double area() {
       double area = side*side;
       return area;
   }
}


public class Rectangle extends Quadilateral {
   public void Rectangle() {
       System.out.print("Please enter length : ");
       int length = scanner.nextInt();
       System.out.print("Please enter breadth : ");
       int breadth = scanner.nextInt();
   }
   public double perimeter() {
       double perimter = 2*(length+breadth);
       return perimeter;
   }
   public double area() {
       double area = length*breadth;
       return area;
   }
}