Hello All,
We're using VB 2010 in class and I have listed the homework problem below
6. Write a program to provide information on the height of a ball thrown straight up into the air. The program should request the initial height, h feet, and the initial velocity,v feet per second, as input. 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 . 1 second and observe when the height
is no longer a positive number.
(c) Display a table showing the height of the ball every quarter second for five seconds or until it hits the ground.
(d) Quit.
Here is my code:
Public Class frmProjectile
Dim MaxHeight As Double
Dim InitialHeight As Double
Dim Velocity As Double
Dim Time As Double
Private Sub btnHeight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMaxHeight.Click
MaxHeight = Velocity / 32
End Sub
Private Sub BtnTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTime.Click
MaxHeight = InitialHeight + Velocity * Time - 16 * Time ^ 2
End Sub
Private Sub btnTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTable.Click
InitialHeight = CDbl(txtHeight.Text)
Velocity = CDbl(txtVelocity.Text)
Time = 0
MaxHeight = 0
Do While MaxHeight >= 0
BtnTime.PerformClick()
btnMaxHeight.PerformClick()
lstOutput.Items.Add(Time & " " & MaxHeight)
Time = Time + 0.25
Loop
End Sub
End Class
When I do my step into, I can see that it's working (or trying to!), but nothing shows in my list box (included a screenshot).
Attachment 98833
The output should look as follows when using the variables 5 for Height and 34 for Velocity:
Attachment 98835
We're using VB 2010 in class and I have listed the homework problem below
6. Write a program to provide information on the height of a ball thrown straight up into the air. The program should request the initial height, h feet, and the initial velocity,v feet per second, as input. 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 . 1 second and observe when the height
is no longer a positive number.
(c) Display a table showing the height of the ball every quarter second for five seconds or until it hits the ground.
(d) Quit.
Here is my code:
Public Class frmProjectile
Dim MaxHeight As Double
Dim InitialHeight As Double
Dim Velocity As Double
Dim Time As Double
Private Sub btnHeight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMaxHeight.Click
MaxHeight = Velocity / 32
End Sub
Private Sub BtnTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTime.Click
MaxHeight = InitialHeight + Velocity * Time - 16 * Time ^ 2
End Sub
Private Sub btnTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTable.Click
InitialHeight = CDbl(txtHeight.Text)
Velocity = CDbl(txtVelocity.Text)
Time = 0
MaxHeight = 0
Do While MaxHeight >= 0
BtnTime.PerformClick()
btnMaxHeight.PerformClick()
lstOutput.Items.Add(Time & " " & MaxHeight)
Time = Time + 0.25
Loop
End Sub
End Class
When I do my step into, I can see that it's working (or trying to!), but nothing shows in my list box (included a screenshot).
Attachment 98833
The output should look as follows when using the variables 5 for Height and 34 for Velocity:
Attachment 98835