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 = C++ A regular polygon is an n-sided polygon in which all sides Angle = are of the same length and all angles have the same degree 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!