public class RandomTest {
public static void main(String[] args) {
for(int i=1; i<=100; i++) {
System.out.print(randomInt(10,20) + "\t");
if(i%10==0) {
System.out.println();
}
}
}
public static double randomDouble() {
double x = Math.random();
return x;
}
public static double randomDouble(int high) {
double x = Math.random();
return x*high;
}
public static double randomDouble(int low, int high) {
if(low > high) {
System.out.println("Error");
return 0.0;
}
double x = Math.random();
return x * (high-low) + low ;
}
public static int randomInt(int low, int high) {
if(low > high) {
System.out.println("Error");
return 0;
}
double x = Math.random();
return (int)(x * (high-low) + low) ;
}
}