Professional Documents
Culture Documents
Projectile Motion
Write a program to provide information on the height of a ball thrown staright up into the
air. The program should request as input the initial height, h feet, and the initial velocity, v
feet per second. The height of the ball (in feet) after t seconds is given by the formula h + vt
+ 16t2 feet. The four options to be provided by buttons are as follows:
a) Determine the maximum height of the ball. (Note: The ball will reach its maximum
height after v/32 seconds.
b) Determine approximately when the ball will hit the ground. (Hint: Calculate the
height after every 0.1 second and determine when the height is no longer a positive
number.
c) Display a table showing the height of the ball every 0.25 second for 5 seconds or
until it hits the ground.
d) Quit
Write the code:
Public Class Form1
Dim h0 As Double = 0
Dim v0 As Double = 0
Dim t As Double = 0
lstOutput.Items.Clear()
InputData()
End If
End Sub
lstOutput.Items.Clear()
InputData()
End If
End Sub
lstOutput.Items.Clear()
InputData()
DisplayTable()
End If
End Sub
Private Sub btnQuit_Click(ByVal sender As Object, ByVal e As EventArgs)
Handles btnQuit.Click
End
End Sub
Sub InputData()
valid = True
If IsNumeric(txtInitialHeight.Text) Then
h0 = CInt(txtInitialHeight.Text)
Else
valid = False
End If
Else
valid = False
End If
If IsNumeric(txtInitialVelocity.Text) Then
v0 = CInt(txtInitialVelocity.Text)
Else
valid = False
End If
Else
valid = False
End If
End Sub
t = v0 / 32
Return CDbl(h0 + (v0 * t) - (16 * t * t))
End Function
t = 0
Do
t += 0.1
Return t
End Function
Sub DisplayTable()
t = 0
Do
t += 0.25
End Sub
End Class
Main Display
Determine Maximum Height