Mar-22-2017, 02:39 AM
(This post was last modified: Mar-22-2017, 02:40 AM by Miraclefruit.)
Write a program to provide information on the height of a ball thrown straight 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 after t seconds is h + vt - 16t2 feet. The program should perform the following two calculations:
(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 determine when the height is no longer a positive
number
I'm getting errors for my main and the ballTime functions. This is what I have so far:
(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 determine when the height is no longer a positive
number
I'm getting errors for my main and the ballTime functions. This is what I have so far:
def main(): h = 0 v = 0 getInput(h, v) def getInput(h, v): h = eval(input("Enter the initial height of the ball: ")) v = eval(input("Enter the initial velocity of the ball: ")) isValid(h,v) def isValid(h,v): if ((h<= 0) or (v <= 0)): print("Please enter positive values") getInput(h,v) else: maxHeight(h,v) def maxHeight(h,v): t = (v/32) maxH = (h + (v*h) - (16*t*t)) print("The maximum height of the ball is", maxH, "feet.") ballTime(h,v) def ballTime(h,v): ballHeight = (h + (v*t) - (16*t*t)) while (ballHeight >= 0): t += 0.1 print("The ball will hit the ground after approximately", t, "seconds.") main()Any help is appreciated, thanks!