lph, your login changed on me and it took a second to figure out who LPH was.
We normally take g=-9.8m/s/s rather than +9.8. Gravity acts down, you're throwing the ball up.
That makes the equation: -4.9t^2+vt=y or -4.9t^2+vt-y=0 or 4.9t^2-vt+y=0.
a=4.9, b=-v, and c=y
t1=(v-√(v²-19.6y))/9.8
t2=(v+√(v²-19.6y))/9.8
You want the time on the way up, which would be the first time, so it looks like you have it.
As for the range settings on the random variables, there is a problem.
You need the discriminant b^2-4ac > 0 in order to have two distinct real roots.
That's v²-19.6y > 0 or y < v²/19.6
That means that you are likely to get imaginary roots with your settings. For example, if v=10.1 and y=10, then v²-19.6y=-94ish
That is, the v=10 only guarantees a root when y=5. If y > 5.1 when v = 10, then there is no real answer to your question.
If you restrict 5<y<10, then you should make sure that v> √(19.6y). That gives you 9.9<v<14, so you would need to make sure that v>14 to guarantee real roots. The upper bound is up to you, it's the lower bound you need to be careful with.
If you restrict 5<y<8, then 9.8<v<12.5, so pick v>12.5.
Note I'm using strict inequalities here, when I say v>12.5, I mean start it at 12.6 or more -- 13 would be better.
If you're only going to ask one question, you could put it in a bank and randomly pick whether the person got the way up or the way down. That would be a lot simpler than using the IF().
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.