Question: PLEASE SOLVE IT AS SSOON AS POSSIBLE! IN JAVA LANGUAGE We have already practiced random numbers. There are several ways to get a pseudo-random number.

PLEASE SOLVE IT AS SSOON AS POSSIBLE! IN JAVA LANGUAGE
We have already practiced random numbers. There are several ways to get a pseudo-random number. You are about to create your own way of pseudo-random number generation. We are about to use the following algorithm: The Lehmer random number generator (named after D. H. Lehmer), is a type of linear congruential generator (LCG) that operates in multiplicative group of integers modulo n. The general formula is: Xx+1 = a + Xx mod m X, is seed (initial value to start the sequence). If user does not want to specify it, by default, take 42. a is multiplier. mis modulus. There are of course constraints to choose Xo, a and m. For practical purposes we will use our own. Main points: 1. Define a class RandomGenerator which will enable user to perform the following operations: a. Instantiate using a seed OR without a seed (in this case, default value of seed is 42) b. int nextInt(); return the next element of the abovementioned sequence (pseudo-random number) c. int nextInt(int bound); returns an integer in the range [O-bound) i. note: the elements of the sequence might be negative as well. d. double nextUniform(): returns an integer in the range [0-1) Explanation (for practical purposes): Assume that we have seed = 1, modulus = 13, multiplier = 3. Normally the sequence looks 39139 139 13...... If with the same setup, we change the seed to 2, then sequence becomes 6526526526...... Test your code with modulus = 2_147_483_647 and multiplier = 243. In the main() method of Question2 class create Random Generator instance and test its methods by printing: 10 random numbers 10 random numbers in range (0-9) 10 random uniform numbers (with 2 digits after decimal) Example Input: Example output RandomGenerator rand = new Random Generator(42); 10206 2480058 602654094 416056778-1977418050 523751002 for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
