Random Function
Understand overloaded methods that generate random numbers of different types.
We'll cover the following...
We'll cover the following...
Problem
Write a program that provides two overloaded random( ) functions. The first one generates an integer random number, whereas the second generates a random number that lies within the range passed to the random( ) function.
Coding solution
Here is a solution to the problem above.
Explanation
The program uses a Linear Congruential Generator (LCG) algorithm that yields a sequence of pseudo-random numbers calculated with a discontinuous piecewise linear equation. The generator is defined by the recurrence relation:
...