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

Write a program to provide information on the height of a ball thrown straight u

ID: 3596643 • Letter: W

Question

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). 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: Determine the maximum height of the ball. Note: The ball will reach its maximum height after v/32 seconds. 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. Display a table showing the height of the ball every quarter second for five seconds or until it hits the ground. Quit. The following diagram shows a possible outcome for the program: Please note that for each of the 3 main buttons (Determine Maximum Height; Display Table; and Determine Approximate Time Until Ball Hits the Ground), you must clear the listbox before directing your output to the listbox. VISUAL BASIC CODING PLS

Explanation / Answer

Private Sub btnGround_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGround.Click
Dim inivelocity, iniheight, height, time As Double
inivelocity = txtVelocity.Text
iniheight = txtHeight.Text
time = 0.01
height = iniheight + 0.1
Do While height > 0
height = iniheight + inivelocity * time - 16 * time * time
time += 0.1
Loop
lstOutput.Items.Clear()
lstOutput.Items.Add("The ball will hit the ground after")
lstOutput.Items.Add("approximately " & time & " seconds")
End Sub

Private Sub btnHeight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHeight.Click
Dim h, v, M As Double
h = txtHeight.Text
v = txtVelocity.Text
M = v / 32
lstOutput.Items.Clear()
lstOutput.Items.Add("The maximum height is " & M & " Feet.")

End Sub

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim inivelocity, iniheight, height, time As Double
inivelocity = txtVelocity.Text
iniheight = txtHeight.Text
lstOutput.Items.Clear()
lstOutput.Items.Add("Time Height")
time = 0
Do While height > 0
height = iniheight + inivelocity * time - 16 * time * time
time = time + 0.25
lstOutput.Items.Add(time & " " & height)
Loop
End Sub

Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
Application.Exit()
End Sub
End Class   

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