Question: Write a Java program to implement your own (not so good) pseudorandom number generator. Your pseudorandom number generator will implement the first pseudorandom number generator

Write a Java program to implement your own (not so good) pseudorandom number generator. Your pseudorandom number generator will implement the first pseudorandom number generator from the WWII era: the middle square method developed by the mathematician and computer science pioneer John von Neumann in 1946.

The method works as follows:

Select a seed (an initial value to get things started

To generate the next number, square the current number

Let the next pseudorandom number be the middle part of the product.

For example:

X X2 Random Number

11 0121 12

12 0144 14

14 0196 19

19 0361 36

36 1296 29

29 0841 84

For your program accept as input any four digit whole number (number between 1,000 and 9,999). When you square it, remove the last two digits and the first two digits. Print out the first 50 pseudorandom numbers in the sequence.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!