The height difference (i only allow them +/- 1 meter) is in regard to where the ball lands. The height differnce is the change in the y-axis (delta_y) this is incorporated into the formula as follows: delta_y = speed_in_y * time + 1/2 * a * time^2 "a" is the acceleration due to gravity. If you rewrite the formula you get... 1/2 * a * time^2 + speed_in_y - delta_y = 0 This can be solved for "time" using the quadratic equation. We know "a" (-9.81 m/s^2) and we know "speed_in_y" (by doing: initial_speed * sin(loft)), and we know delta_y (because it's the random number +/- 1 meter that is generated first). So the only thing you don't know is "time". You can solve for the two roots of the quadratic. Only the 2nd root matters because the first is time zero (the time of launch). The 2nd is when the ball lands. Now that you know "time" and speed_in_x (by doing: inital_speed * cos(loft)), you can solve for "distance" (in the x direction)... just multiply: distance_in_x = speed_in_x * time FAQ. ---- -- Q. You don't care about the height of the ball when it falls, do you? You do not print any target height at the end... How does the height enter the picture? You are saying that even when the ball does not fall in the hole, it falls always at the target height? What about extreme terrains? How do you compute these things? A. The *unfortunate* answer is "yes" - i always assume that the ball lands at target height. I thought about this, but not enough to figure out how to solve it. This is why for now i've put a limit of +/- 1 meter. It doesn't affect the results... which are *extremely* accurate with real life.... like within a few yards. -- Q. My program apparently pauses sometime after the first decimal input (nextDecimal), and before or during the next input (which happens to be string input, using nextLine). What is wrong? How can I fix this problem? Try putting the following statement immediately after your nextDecimal() call: scan.skip("\n"); The intent is to skip the ENTER character. The reason why it may not be working for you (if you try it with "\n") is because the ENTER key is interpreted in different ways on different operating systems. If you're using Windows, you may want to try skip'ing the carriage return ("\r"). However, if that works, you may want to change it back to "\n" before submitting, as the marker will be using a Unix-like system... not Windows. If skip doesn't work with \n or \r, then you can try the scan.nextLine() statement because it too will just eat up the ENTER character in the buffer (from the first nextDecimal call). -- Q. How do I format the numbers as required in the assignment? Here's a hint: int yards_to_hole = ....... int meters_to_hole = (int) ....... Also, you will have to show some numbers with ONE decimal point and others with TWO decimal points. Just create two DecimalFormat objects... You only need to use one string to state the target position... if you setup your numbers in the way that mentioned above, you will see that this is natural and easy... you will *not* need two strings. -- Q. What is the URL to the java file containing comments for assignment 2? It's listed at the bottom of the PDF file describing assignment 2.... though you may have an earlier version. Here's the direct link, for your convenience: http://www.cs.mcgill.ca/~abatko/cs202/assignments/ass02/GolfPracticeRange.java