Problem Spots:
- Creating the Random object repeatedly.
- If this is created in the innermost loop (where they generate the
next (x,y) point), then they'll end up getting non-random numbers, since
each object will be initialized with the current clock time (in
milliseconds), and their computer is fast enough to repeatedly create
multiple Random objects within the same millisecond
- Integer vs. real division
- This sometimes afflicts people who are trying to calculate the
percentage / error towards the end. If the count of hits inside
the circle is an integer, and the total number of points is an integer,
and you simply divide them - voila! - you've got this problem.
|