Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have all the code done! I just need help incerting the code into the windows f

ID: 3689696 • Letter: I

Question

I have all the code done! I just need help incerting the code into the windows form and if theres anything I missed feel free to fill it in. thank you

these are the constraints I had to follow, now I just need to incert the code I have written on the bottom into my form to make it run.

create a interactive Windows form program to calculate the area and volume of some spherical shapes, specifically a circle, sphere, and cylinder.

1. The two inputs are the radius and the height.

2.If the height is zero you are to calculate the area and volume of a circle and a sphere.

3.If the height is greater than zero than you are to calculate only the area and volume of a cylinder.

You should create three classes: one for sphere, one for circle and one for cylinder. Methods and attributes unique to the geometric shapes should be part of that respective class.

Additionally, the radius should be constrained between 0 and 50 and the height should be constrained between 0 and 100.

Im using visual studio 2015. Code Language is: Visual Basic

here is my Visual Studios code for the form I have created:

--------This is my windows form code-------

Public Class Form1
    Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click

    End Sub

    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click

    End Sub

    Private Sub txtInputRadius_TextChanged(sender As Object, e As EventArgs) Handles txtInputRadius.TextChanged

    End Sub

    Private Sub txtInputHeight_TextChanged(sender As Object, e As EventArgs) Handles txtInputHeight.TextChanged

    End Sub

    Private Sub txtCircleArea_TextChanged(sender As Object, e As EventArgs) Handles txtCircleArea.TextChanged

    End Sub

    Private Sub txtCircleVolume_TextChanged(sender As Object, e As EventArgs) Handles txtCircleVolume.TextChanged

    End Sub

    Private Sub txtSphereArea_TextChanged(sender As Object, e As EventArgs) Handles txtSphereArea.TextChanged

    End Sub

    Private Sub txtSphereVolume_TextChanged(sender As Object, e As EventArgs) Handles txtSphereVolume.TextChanged

    End Sub

    Private Sub txtCylinderArea_TextChanged(sender As Object, e As EventArgs) Handles txtCylinderArea.TextChanged

    End Sub

    Private Sub txtCylinderVolume_TextChanged(sender As Object, e As EventArgs) Handles txtCylinderVolume.TextChanged

    End Sub


End Class

-------------This is my visual basic code that goes into the windows form-------

const PI as Single=3.1419

sub heightAndRadius(ByRef r as Single, ByRef h as Single)

do

    console.writeline("Enter Height (0-100): ")

    h=CSng(console.readline())

loop until not h>=0 or h<=100

do

    console.writeline("Enter Radius (1-50): ")

    r=CSng(console.readline())

loop until not r>=1 or r<=50

end sub

Function CalcCircleArea(ByVal r as Single) as single

    Return PI*r*r

End function

Function CalcSphereArea(ByVal r as Single) as Single

    Return 4*PI*r*r

End Function

Function CalcCylinderArea(ByVal r as single,h as Single) as Single

    Return (2*PI*r*h)+(2*PI*r*r)

End Function

Sub DisplayCircleArea (byVal CircleArea as Single)

    Console.writeline ("The Area of the Circle is: " & CircleArea)

End Sub

Sub DisplaySphereArea (byVal SphereArea as Single)

    Console.writeline ("The Area of the Sphere is: " & SphereArea)

End Sub

Sub DisplayCylinderArea (byVal CylinderArea as Single)

    Console.writeline ("The Area of the Cylinder is: " & CylinderArea)

End Sub

Function AskAnotherRun() as Char

    dim entry as char

    Console.WriteLine("Do you want to continue for one more time? (y/n)")

    entry=Convert.ToChar(Console.Read())

    return entry

End Function

Sub main()

    Dim r as single

    Dim h as single

    Dim circleArea as single

    Dim sphereArea as single

    Dim cylinderArea as single

    Dim anotherRun as char

   

   Do

    heightAndRadius(r,h)   

If h=0 then

   

        circleArea=CalcCircleArea(r)

        sphereArea=CalcSphereArea(r)

       

        DisplayCircleArea(circleArea)

        DisplaySphereArea(sphereArea)

    else

        cylinderArea=CalcCylinderArea(r,h)

        DisplayCylinderArea(cylinderArea)

    End If

   

    anotherRun=UCase(AskAnotherRun())

    Console.ReadLine()

    Loop until anotherRun = "N"

   

End Sub

Explanation / Answer

sub heightAndRadius(ByRef r as Single, ByRef h as Single)

do
console.writeline("Enter Height (0-100): ")
h=CSng(console.readline())
loop until not h>=0 or h<=100

do
console.writeline("Enter Radius (1-50): ")
r=CSng(console.readline())
loop until not r>=1 or r<=50

end sub

Function CalcCircleArea(ByVal r as Single) as single
Return PI*r*r
End function

Function CalcSphereArea(ByVal r as Single) as Single
Return 4*PI*r*r
End Function

Function CalcCylinderArea(ByVal r as single,h as Single) as Single
Return (2*PI*r*h)+(2*PI*r*r)
End Function

Sub DisplayCircleArea (byVal CircleArea as Single)
Console.writeline ("The Area of the Circle is: " & CircleArea)
End Sub

Sub DisplaySphereArea (byVal SphereArea as Single)
Console.writeline ("The Area of the Sphere is: " & SphereArea)
End Sub

Sub DisplayCylinderArea (byVal CylinderArea as Single)
Console.writeline ("The Area of the Cylinder is: " & CylinderArea)
End Sub

Function CalcCircleVolume(ByVal r as Single) as single
Return 2*PI*r
End function

Function CalcSphereVolume(ByVal r as Single) as Single
Return 4/3*PI*r*r*r
End Function

Function CalcCylinderVolume(ByVal r as single,h as Single) as Single
Return PI*r*r*h
End Function

Sub DisplayCircleVolume (byVal CircleVolume as Single)
Console.writeline ("The Volume of the Circle is: " & CircleVolume)
End Sub

Sub DisplaySphereVolume (byVal SphereVolume as Single)
Console.writeline ("The Volume of the Sphere is: " & SphereVolume)
End Sub

Sub DisplayCylinderVolume (byVal CylinderVolume as Single)
Console.writeline ("The Volume of the Cylinder is: " & CylinderVolume)
End Sub

Function AskAnotherRun() as Char
dim entry as char
Console.WriteLine("Do you want to continue for one more time? (y/n)")
entry=Convert.ToChar(Console.Read())
return entry
End Function

Sub main()
Dim r as single
Dim h as single
Dim circleArea as single
Dim sphereArea as single
Dim cylinderArea as single
Dim circleVolume as single
Dim sphereVolume as single
Dim cylinderVolume as single
Dim anotherRun as char

Do
heightAndRadius(r,h)   
If h=0 then

circleArea=CalcCircleArea(r)
sphereArea=CalcSphereArea(r)
circleVolume=CalcCircleVolume(r)
sphereVolume=CalcSphereVolume(r)

DisplayCircleArea(circleArea)
DisplaySphereArea(sphereArea)
DisplayCircleVolume(circleVolume)
DisplaySphereVolume(sphereVolume)
else
cylinderArea=CalcCylinderArea(r,h)
cylinderVolume=CalcCylinderVolume(r,h)
  
DisplayCylinderArea(cylinderArea)
DisplayCylinderVolume(cylinderVolume)
End If

anotherRun=UCase(AskAnotherRun())
Console.ReadLine()
Loop until anotherRun = "N"

End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote