How to calculate the volume of a sphere in VB.NET

2 Answers

0 votes
Imports System
 
Public Class CalculateVolumeSphere
	Public Shared Function sphereVolume(r As Double) As Double
 
        Return 4.0 / 3.0 * Math.PI * Math.Pow(r, 3)
 
    End Function
	
    Public Shared Sub Main()
        Dim radius As Integer = 5
         
        Console.Write("Volume of sphere = " & sphereVolume(radius))
    End Sub
End Class


' run:
'
' Volume of sphere = 523.598775598299
'
 
   

 



answered Mar 7, 2018 by avibootz
edited Sep 14, 2024 by avibootz
0 votes
Imports System
 
Public Class CalculateVolumeSphere
    Public Shared Sub Main()
         Dim r As Double = 3
         
        Dim volume As Double = (4 / 3.0) * Math.PI * (r * r * r)
         
        Console.Write("Volume of sphere = " & volume)
    End Sub
End Class


' run:
'
' Volume of sphere = 113.097335529233
'

 



answered Sep 14, 2024 by avibootz

Related questions

1 answer 215 views
1 answer 102 views
1 answer 111 views
1 answer 107 views
1 answer 164 views
1 answer 162 views
1 answer 146 views
...