Mar-22-2017, 03:52 PM
(This post was last modified: Mar-22-2017, 04:07 PM by Miraclefruit.)
[quote pid='12946' dateline='1490173276']
This seems to be working:
[/quote]
This seems to be working:
[/quote]
def getInput(): h = int(input("Enter the initial height of the ball: ")) v = int(input("Enter the initial velocity of the ball: ")) isValid(h,v) def isValid(h,v): if (h<= 0): print("Please enter positive values") elif(v<= 0): print("Please enter positive values") else: height = maxHeight(h,v) print("The maximum height of the ball is", height, "feet.") groundTime = ballTime(h,v) print("The ball will hit the ground after approximately", groundTime, "seconds.") def maxHeight(h,v): t = (v/32) maxH = (h + (v*t) - (16*t*t)) return maxH def ballTime(h,v): t = 0.1 while(True): ballHeight = (h + (v*t) - (16*t*t)) if (ballHeight <= 0): break else: t += 0.1 return t getInput()