Question:
How can I do a Math.random() to generate a random number between a and b
Code:
public class Example { public static void main(String[] args) { double a=10; double b=20; double range = b - a; double r = Math.random() * range + a; System.out.println(r); } }
Output:
$ java Example 17.09178855580154