S
strutsng
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)
{ numHeads++;
return "H";
}
numTails++;
return "T";
}
Thanks!!
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)
{ numHeads++;
return "H";
}
numTails++;
return "T";
}
Thanks!!