(a) Implement a class that can generate a sequence of pseudorandominterger by (m
ID: 3607967 • Letter: #
Question
(a) Implement a class that can generate a sequence of pseudorandominterger by (multiplier * seed + increment) % modulus Each time a new randomnumber is computed, the value of theseed os changed to that new number. For example, seed=1 multiplier=40 increment=3641 modulus=729,the first number is ((40*1)+3641)%729 =36. And the next number is((40*36)+3641)%729=707 The initial seed, multiplier, increment, and modulus shouldall be parameter of the constructor. There should also be a method to permit the seed to be changedand a method to generate and return the net number in thesequence. (b) add a new method that generate the random number as above butnot return it directely. In stead, return the number divided bymodulus. So the return value from this new method will be a doublenumber in the range [0..1) (c) Run the new method and create a table by devide the range into10 interval like [0.0..0.1) 99889[0.1..0.2) 100309
[0.2..0.3) 100070
[0.3..0.4) 99940
[0.4..0.5) 99584
[0.5..0.6) 100028
[0.6..0.7) 99669
[0.7..0.8) 100100
[0.8..0.9) 100107
[0.9..1.0) 100304
Thank you! (a) Implement a class that can generate a sequence of pseudorandominterger by (multiplier * seed + increment) % modulus Each time a new randomnumber is computed, the value of theseed os changed to that new number. For example, seed=1 multiplier=40 increment=3641 modulus=729,the first number is ((40*1)+3641)%729 =36. And the next number is((40*36)+3641)%729=707 The initial seed, multiplier, increment, and modulus shouldall be parameter of the constructor. There should also be a method to permit the seed to be changedand a method to generate and return the net number in thesequence. (b) add a new method that generate the random number as above butnot return it directely. In stead, return the number divided bymodulus. So the return value from this new method will be a doublenumber in the range [0..1) (c) Run the new method and create a table by devide the range into10 interval like [0.0..0.1) 99889
[0.1..0.2) 100309
[0.2..0.3) 100070
[0.3..0.4) 99940
[0.4..0.5) 99584
[0.5..0.6) 100028
[0.6..0.7) 99669
[0.7..0.8) 100100
[0.8..0.9) 100107
[0.9..1.0) 100304
Thank you!
Explanation / Answer
(a) Implement a class that can generate a sequence of pseudorandominterger by (m
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.