Random number generators By Bartek Wohlert and Arrian Torres
What is a random number generator Java uses what is called a Linear Congruential Method to generate a random number Java includes the Random class in the java.util package for generating random numbers.
What is a random number generator? A random number generator is simply enough a tool that allows the person who's making the code to generate a random number. Because the sequence eventually repeats, random number in a computer application are really pseudorandom.
What is a random Number Generator? It can either return a random integer or a random double integer They can have a specified range. i.e: 1-10
Why do we use a random number generator? A random number generator has many different and valuable uses to it For most reasons, using a random number generator can help make a guessing game created in java function much more better For more grander reasons, random number generators are used in lotteries with very difficult algorithms to break.
An example of a random number generator To generate a random number in a range this code is used to do that (high – low + 1) * Math.random() + low Note that high represents the largest number & low the lowest number in the range. To randomly generate a number between 1-10: (10 – 1 + 1) * Math.random() + 1
An example of a random number generator
Variations of a random number generator There are different variants to the random number generator. A basic change that can be done is determining the range that your random number generator You can also generate a number in double or int form Double: 0.0 – 1.0 Int:1-10