Interesting question.
For the ball to be going straight up to an observer, the student must be throwing the ball opposite the direction of the train, such that the horizontal component of the ball's motion exactly equals the speed of the train. Call the (unknown) velocity of the ball B. B * sin(54 degrees) is the ball's vertical velocity, and B * cos(54 degrees) is its horizontal velocity. Thus we solve for B, knowing
B * cos(54 degrees) = 17 m / s.
B = 28.9 m / sec.
Now we can compute the ball's vertical velocity easily as B sin(54 degrees), or 23.4 m / s.
As a final step you compute the height of a ball thrown straight up at that speed under the force of gravity, 9.8 m / s^2. First compute how long it takes the ball to come to a stop at its maximum height; 23.4 m/s / 9.8 m/s^2 = 2.39 seconds. Finally, use the displacement equation
s = v0 t + 1/2 a t^2
to find the ball's maximum height, with v0 = 23.4, t = 2.39, a = -9.8. You get 27.9 meters.