Question
C++ A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e.,
C++
A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon and the formula for computing the angle of a regular polygon are below.
Area = Angle = where: n is the number of sides, and s is the length of each side
Create a class named Polygon according to the following:
class Polygon {
private:
int numberOfSides;
double sideLength;
public:
Polygon(int, double) {}
int getNumberOfSides() {}
double getSideLength() {}
void setNumberOfSides(int n) {}
void setSideLength(double s) {}
double getArea() {}
double getInteriorAngle() {}
};
Write the one constructor, and the accessor and mutator functions listed in the diagram. Next, using the formulas above, write a function to return the area of the polygon and a function to return the angle. Required header: cmath (and others) Finally, write a main function to demonstrate your Polygon class. Create 3 to 5 polygon objects. Use an array, and/or create them dynamically. Demonstrate changing the length of the sides and changing the number of sides. Make sure to display (describe) each polygon before and after changes are made.
*s2 4 * tan()Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started