Question: C++ Problem #1: Polygon vs. circle (You can do it!) Design a class named Circle to represent a circle and a class named Polygon to
C++ Problem #1: Polygon vs. circle (You can do it!)
Design a class named Circle to represent a circle and a class named Polygon to represent a regular polygon.
Implement the classes (header and implementation files) using the following UML diagrams:
a.
| Circle | |
| -r: double | The radius, r, of the circle (default: 0) |
| +Circle() +Circle(r: double) +getArea(): double +getPerimeter(): double +getRadius(): double +setRadius(r: double) void | Constructs a default circle object Constructs a circle with specified radius Returns the area of this circle Returns the perimeter of this circle Returns the radius of this circle Sets a new radius, r, to this circle |
| Polygon | |
| -R: double -n: int | The circumradius, R, of the polygon (default:0) The number of sides, n, of the polygon (default: 3) |
| +Polygon() +getArea(): double const +getPerimeter(): double const +getApothem: double const +getSideNumber: int const +getSideLength: double const +getInteriorAngle(): double const +getExteriorAngle(): double const +setSideNumber(sideNumber: double) void +setCircumRadius(radius: double) void | Constructs a default polygon object Returns the area of this polygon Returns the perimeter of this polygon Returns the apothem of this polygon Returns the number of sides of this polygon Returns the length side of this polygon Returns the interior angle of this polygon Returns the exterior angle of this polygon Sets a new number of sides to this polygon Sets a new circumradius to this polygon |
b. Write a test program that
i.Randomly generate a double value ranging 1300 for X.
ii.Create one Circle object and assign radius of X
iii.Create 100 regular polygon objects, and assign circumradius of X and set the number of sides starting at 3 and increment by 1.
iv.Find the average area and perimeter of the 100 regular polygons.
v.Print a table of information of those 100 regular polygons.
Regular n-polygon where
n - number of sides
a - apothem
r - innerradius
R - circumradius
A - areas
P - perimeter
x - interior angle
y - exterior angle
Example output:

vi. Print the area and perimeter of the circle and the average area and perimeter of the regular polygons, and their differences.
Example output:

The program output has to look exactly like the pictures above (numbers are the only exception as they have to be randomly generated!)
Thank you in advance!
egular n-polygon where numbeF Of sidles - apothem 1nnerradius R circumr aeas perimeter - interior angle - exterior angle 12.09 20.940 6.045 189.878 62.821 60.000 120.000 12.09 17.098 8.549 292.336 68.391 90.000 90.000 12.09 14.213 9.781 347.535 71.063 198.000 72.000 12.09 12.090 10.470 379.756 72.540 120.000 60.000 12.09 10.491 10.893 399.976 73.439 128.571 51.429 12.0909.253 11.170 413.42674.026 135.000 45.000 12.090 8.270 11.361 422.797 74.430 140.000 40.000 12.0907.47211.498 429.577 74.720 144.000 36.000 12.09 6.812 11.600 434.63474.935 147.273 32.727 12.09 6.258 11.678 438.504 75.099 150.000 30.000 12.0905.787 11.739 441.530 75.226 152.308 27.692 12.09 5.381 11.787 443.939 75.328 154.286 25.714 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
