How to calculate the area of a pentagon in VB.NET

2 Answers

0 votes
Imports System

Module Program

    Function PentagonArea(side As Single, apothem As Single) As Single
        Return 5.0F * (side * apothem) / 2.0F
    End Function

    Sub Main()
        Dim side As Single = 5.0F
        Dim apothem As Single = 3.0F

        Dim area As Single = PentagonArea(side, apothem)

        Console.WriteLine($"Area = {area:F2}")
    End Sub

End Module



'
' run:
'
' Area = 37.50
'

 



answered Jul 12, 2021 by avibootz
edited 4 hours ago by avibootz
0 votes
Imports System

Module Program

    Function area_regular_pentagon(side As Double) As Double
        Return (1.0 / 4.0) * Math.Sqrt(5.0 * (5.0 + 2.0 * Math.Sqrt(5.0))) * (side ^ 2)
    End Function

    Sub Main()
        Console.WriteLine(area_regular_pentagon(7.0))
    End Sub

End Module


'
' run:
'
' 84.30339262885938
'

 



answered 3 hours ago by avibootz
...