Write a circle class with a private data member that is the radius (r) of the circle, and a parameterized
constructor that sets the value of the radius (r). In addition, the class includes common methods, such as
calculating the circumference of a circle, calculating the area of a circle, and getting the radius of a circle.
Enter the radius of the circle in the console to calculate and show the circumference and area of the circle.
Imports System.IO
Class Circle
Private _radius As Double
Sub New(ByVal radius As Double)
Me._radius = radius
End Sub
Function getRadius()
Return _radius
End Function
Function calculateArea()
Return Math.PI * _radius * _radius
End Function
Function calculateCircumference()
Return 2 * Math.PI * _radius
End Function
End Class
Module Module1
Sub Main()
Console.Write("Enter the radius of the circle: ")
Dim _radius As Double = Double.Parse(Console.ReadLine())
Dim circle As New Circle(_radius)
Console.WriteLine("The radius of the circle: " + circle.getRadius().ToString())
Console.WriteLine("The circumference of the circle: " + circle.calculateCircumference().ToString())
Console.WriteLine("The area of the circle: " + circle.calculateArea().ToString())
Console.ReadLine()
End Sub
End Module
Comments
Leave a comment