(E-Mail Removed) writes:

> I need to write a flip method that returns equal chance of head or

> tail. Do you think a test for x % 2 is "equal chance"? Well, random

> number generator never gets result "equal chance." Is that correct?

>

> Here's my attempts, please advise.

>

> public String flip()

> { Random r = new Random();

> int x = r.nextInt();

> if (x % 2 == 0)
Learn about java.util.Random instead, and for heads and tails use its

nextBoolean() method. As the other guy said, move the generator out of

the method; only initialize it once. Now you are really just sampling

the current time, which is not a random generator at all.