Annje Tref
asked on
nextBoolean(double p) for Random class
I need to create a method using Random class which would return true with specified odds. I tried using a loop but it returns true all the time?
Here it is:
Here it is:
public boolean nextBoolean(double p) {
double n = rgen.nextDouble()*(p+0.1) ;
for (double i= 0.0; i <= n;) {
return true;
}
return false;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER