Generating random numbers.

How can I generate a random number between a range of numbers using a number generated by Math.random ()? I know in order to get a number between 0 and n, I simply have to multiply Math.random () by n, but I can't figure out how to do it between a range of m and n. Any ideas? It's an exercise in a textbook I'm learning from:

Exercise 10.1 Write a method called randomDouble that takes two doubles, low

and high, and that returns a random double x so that low x < high.

Exercise 10.2 Write a method called randomInt that takes two arguments, low and

high, and that returns a random integer between low and high (including both).

Re: Generating random numbers.

Try this on some paper. Write down a bunch of random numbers between 0 and n. Then add some constant m to each one. See what happens.

Regards,

Jim