Answer:
Here the code is by using java.
Explanation:
//Randomizer.java
public class Randomizer {
public static int nextInt() {
//get random number from 1-10
int randInteger = (int) (Math.random() * (11) + 1);
//if number is greater than 10 or less than 1
while (randInteger > 10 || randInteger < 1) {
randInteger = (int) (Math.random() * (11) + 1);
}
return randInteger;
}
public static int nextInt(int min, int max) {
//formula to get random number from min-max
int randInteger = (int) (Math.random() * (max + 1) + min);
while (randInteger > max || randInteger < min) {
randInteger = (int) (Math.random() * (max + 1) + min);
}
return randInteger;
}
}
//RandomizerTester.java
public class RandomizerTester {
public static void main(String[] args) {
System.out.println("Results of Randommizer.nextInt()");
for (int i = 0; i < 10; i++) {
System.out.println(Randomizer.nextInt());
}
int min = 5;
int max = 10;
System.out.println("\n Results of Randomizer.nextInt(5,10)");
for (int i = 0; i < 10; i++) {
System.out.println(Randomizer.nextInt(min, max));
}
}
}
OUTPUT:
Results of Randommizer.nextInt()
9
2
3
8
5
9
4
1
9
2
Results of Randomizer.nextInt(5,10)
9
8
9
7
5
10
5
10
7
7