For calculate the area of a pentagon, “a” and “r” length must be known.
You see a triangle in the bottom picture. After calculating the area of the triangle, the area of the pentagon can be found by multiplying with 5.
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class Program { static void Main(string[] args) { double a, r, area, perimeter; Console.Write("input the border length: "); a = Convert.ToDouble(Console.ReadLine()); Console.Write("input radius (r): "); r = Convert.ToDouble(Console.ReadLine()); area = 5 * ((a * r) / 2); perimeter = 5 * a; Console.WriteLine("Pentagon perimeter : {0}", perimeter); Console.WriteLine("Pentagon area : {0}", area); Console.ReadKey(); } } |
Output: