Brief Algorithm.
1. Get the number of sides of the polygon and the length of the side.
2. Checking the correctness of the entered data. Displaying a message in
case of erroneous input.
3. Calculating the perimeter of a polygon using the formula:
P = a*n, where
a - polygon side length
n - number of sides of a polygon
4. We calculate the radius of the inscribed circle by the formula:
r = a/(2*Tan(180/n))
We take into account the fact that when calculating the tangent,
the value is taken in degrees
5. We calculate the area of the polygon using the formula:
S = Pr/2
6. We display the obtained results of the perimeter and area
Pseudocode
START
INPUT a,n
\\ check correct input
IF (a>0, n is integer,n>0)
P = a*n
r = a/(2*Tan(180/n))
S = Pr/2
OUTPUT P,S
ElSE
OUTPUT message incorrect data entry
ENDIF
END
Comments
Leave a comment