THIS USER ASKED 👇
Which of the following expression yields an integer between 0 and 100, inclusive?
A. (int)(Math. random() * 100 + 1)
B. (int)(Math. random() * 101)
C. (int)(Math. random() * 100)
D. (int)(Math. random() * 100) + 1
THIS IS THE BEST ANSWER 👇
B. (int) (Math.random () * 101)
The function designed as Math.random acts as a float for pseudorandom number with the range between [0,1] which simply means starting from 0 (all) to but instead of 1 (exclusive), the design can now be scaled to the optimal desired range.
For example, we needed 100 inclusive, we have 101 exclusive since we need to scale to 101.