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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started