Module Module1
Sub Main()
'do some procedural programming
'user enters a number and gets back the number squared
Console.WriteLine("Please enter a number")
Dim a As Integer = Console.ReadLine
Dim newNumber = a * a 'squared the number
Dim newNumber2 = a ^ 2
Dim newNumber3 = Math.Pow(a, 2)
Console.WriteLine(newNumber)
Console.WriteLine(newNumber2)
Console.WriteLine(newNumber3)
'ask the user for the side of a square. give the user back the perimeter and area.
Console.WriteLine("Please enter the side of a square:")
Dim sideOfSquare As Decimal = Console.ReadLine
Console.WriteLine("The area is " & calculateArea(sideOfSquare))
Console.WriteLine("The perimeter is " & calculatePerimeter(sideOfSquare))
Console.WriteLine("The area of a circle with a radius of 10 is " & calculateAreaOfCircle(10.0))
Console.ReadLine()
End Sub
Function calculatePerimeter(ByVal side As Decimal) As Decimal
Return side * 4
End Function
Function calculateArea(ByVal side As Decimal) As Decimal
Return side * side
End Function
'define a function that calculates the area of a circle given the radius!
Function calculateAreaOfCircle(ByVal radius As Decimal) As Decimal
'pi* r^2
Return Math.PI * (radius ^ 2)
End Function
End Module
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment