Answer to Question #300325 in Visual Basic for Moha

Question #300325

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.

1
Expert's answer
2022-02-20T14:40:21-0500


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

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS