Question #235479

How do I write an algorithm, pseudocode and flowchart to find the perimeter and area of a regular polygon

Expert's answer

 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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS