Description: Two different approaches on how to generate random numbers using Java.
Method 1: using the Math library and the method random(). This method requires some "manipulation" since the Math.random() generates random numbers [0,1) not including 1. It also generates double numbers, and it might require to use of type casting to manipulate the data type.
Method 2: using the Random object from java. It is required to import the library: import java.util.Random; This object contains several methods, including .nextInt(). This method avoids the manipulation from the previous method, however, it requires the usage of the object Random.
Code:
ACM Learning Outcomes
[AL-06] Investigate the use of random/pseudo random number generation in cybersecurity applications.
APCS-A
[CON-1.D.4] The values returned from Math.random can be manipulated to produce a random int or double in a defined range
CS 1
[130.421.c.4.w] Generate and use random numbers.
CS 2
[130.422.c.4.s] Use random algorithms to create simulations that model the real world