Question: language java An n sided regular polygon's sides all have the same length and all of its angles have the same degrees ( i .
language java
An n sided regular polygon's sides all have the same length and all of its angles have the same degrees ie the polygon is both equilateral and equiangular Design a class named RegularPolygon that contains:
A private int data field named n that defines the number of sides in the polygon
A private double data field named side that stores the length of the side
A private double data field named x that defines the x coordinate of the center of the polygon with default value
A private double data field named y that defines the y coordinate of the center of the polygon with default value
A constructor that creates a regular polygon with the specified n default side default x default and y default
The accessor and mutator methods for all data fields
the method getPerimeter that returns the perimeter of the polygon
the method getArea that returns the area of the polygon. The formula for computing the area of a regular polygon is area n side tanpin
Implement the class. Write a test program that creates RegularPolygon objects, created using RegularPolygon using RegularPolygon and RegularPolygon For each object display its perimeter and area.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
