Sorry but would the easier way to go about finding the maximum height be by using:
v^2 = u^2 + 2ar
being
0 = (40)^2 + 2 (-9.8) r
therefore straight away giving you the value of r being the distance?
I know that the answer will be the same answer, but what do you guys think would...