<p>Write a program to provide information on the height of a ball thrown straigh
ID: 3646776 • Letter: #
Question
<p>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 max height after v/32 seconds b) Determine approx. 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 give seconds or until it hits the ground. d) Quit The formula for the height of the ball after t seconds, h + v*t – 16* t * t, should be specified in a user-defined function. (Test the program with v = 148 and h = 0. This velocity is approx. the top speed clocked for a ball thrown by a professional baseball pitcher.)</p>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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.