Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 = image text in transcribed Angle = image text in transcribed 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

What information remains to be obtained?

Answered: 1 week ago