Sphere, float Learn programming Visual Basic (VB.net)


Basic Data Types


Sphere, float


Calculate the surface area and volume of a sphere, given its radius (surface area = 4 * pi * radius squared; volume = 4/3 * pi * radius cubed).

Note: For floating-point numbers, you should use Convert.ToSingle(...)


Imports System
Public Class exercise59
    Public Shared Sub Main()
        Dim radius As Single
        Dim pi As Single = 3.1415926535F
        Console.Write("Radius? ")
        radius = Convert.ToSingle(Console.ReadLine())
        Console.WriteLine(4 * pi * (radius * radius))
        Console.WriteLine(4 / 3 * pi * (radius * radius * radius))
    End Sub
End Class

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.