0% found this document useful (0 votes)
51 views7 pages

Group Assignment (5%) - (DUE DATE: 2 DECEMBER) : + 16t Feet. The Four Options To Be Provided by Buttons Are As Follows

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 app

Uploaded by

Eponlee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views7 pages

Group Assignment (5%) - (DUE DATE: 2 DECEMBER) : + 16t Feet. The Four Options To Be Provided by Buttons Are As Follows

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 app

Uploaded by

Eponlee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Group Assignment (5%) – (DUE DATE: 2 DECEMBER}

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 ballHeight As Double = 0

Dim h0 As Double = 0

Dim v0 As Double = 0

Dim t As Double = 0

Dim valid As Boolean = True

Private Sub btnMaxHeight_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnMaxHeight.Click

lstOutput.Items.Clear()

InputData()

If valid = True Then

lstOutput.Items.Add("The maximum height is ")

lstOutput.Items.Add(MaxHeight() & "feet.")

End If

End Sub

Private Sub btnApproxTime_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnApproxTime.Click

lstOutput.Items.Clear()

InputData()

If valid = True Then

lstOutput.Items.Add("The ball will hit the ground after")

lstOutput.Items.Add("approximately " & timeInAir() & " seconds.")

End If

End Sub

Private Sub btnTable_Click(ByVal sender As Object, ByVal e As EventArgs)


Handles btnTable.Click

lstOutput.Items.Clear()

InputData()

If valid = True Then

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

If CInt(txtInitialHeight.Text) >= 0 Then

h0 = CInt(txtInitialHeight.Text)

Else

MessageBox.Show("You entered a negative number. Please try


again.")

valid = False

End If

Else

MessageBox.Show("You did not enter a numeric value. Please try


again.")

valid = False

End If

If IsNumeric(txtInitialVelocity.Text) Then

If CInt(txtInitialVelocity.Text) >= 0 Then

v0 = CInt(txtInitialVelocity.Text)

Else

MessageBox.Show("You entered a negative number. Please try


again.")

valid = False

End If

Else

MessageBox.Show("You did not enter a numeric value. Please try


again.")

valid = False

End If

End Sub

Function maxHeight() As Double

t = v0 / 32
Return CDbl(h0 + (v0 * t) - (16 * t * t))

End Function

Function timeInAir() As Double

t = 0

ballHeight = CDbl(h0 + (v0 * t) - (16 * t * t))

Do

t += 0.1

ballHeight = CDbl(h0 + (v0 * t) - (16 * t * t))

Loop Until (ballHeight <= 0)

Return t

End Function

Sub DisplayTable()

t = 0

ballHeight = CDbl(h0 + (v0 * t) - (16 * t * t))

lstOutput.Items.Add("Time" & vbTab & "Height")

lstOutput.Items.Add(t.ToString("N2") & vbTab & ballHeight)

Do

t += 0.25

ballHeight = CDbl(h0 + (v0 * t) - (16 * t * t))

lstOutput.Items.Add(t.ToString("N2") & vbTab &


ballHeight.ToString("N1"))

Loop Until ((ballHeight <= 0) Or (t = 5))

End Sub

End Class
Main Display
Determine Maximum Height

Determine approximate time untill ball hits the ground


Display table

You might also like