Hi guys,
Being really thick here...
I'm trying to generate a random number between 0.3 and 1.
I have written the following basic code, but can't work out why it's not working (It's returning numbers <=0.3)!
Any help appreciated, cheers.
Being really thick here...
I'm trying to generate a random number between 0.3 and 1.
I have written the following basic code, but can't work out why it's not working (It's returning numbers <=0.3)!
Code:
public class Random
{
private double x;
public Random()
{
for(int i=0; i<10; i++){
x=getRandomNumber();
System.out.println(x);
}
}
public double getRandomNumber()
{
double a;
a=(Math.random());
if(a<=0.3) {
getRandomNumber();
}
return a;
}
}
Any help appreciated, cheers.