1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
/**Suppose max and min are correctly instantiated int variables—
* what is the range that this call will generate?
*/
System.out.println(Math.random());
[0, 1)
/**Suppose max and min are correctly instantiated int variables—
* what is the range that this call will generate?
*/
System.out.println(Math.random() * n);
[0, n)
/**Suppose max and min are correctly instantiated int variables—
* what is the range that this call will generate?
*/
System.out.println(Math.random() + n);
[0 + n, 1 + n)
/**Suppose max and min are correctly instantiated int variables—
* what is the range that this call will generate?
*/
System.out.println((Math.random()*(max - min)) + min);
[min, max)
/**What is the range that this call will generate?
* Pay attention to the casting call!
*/
System.out.println((int)(Math.random());
0
**Suppose n is a correctly instantiated int variable—
* what is the range that this call will generate?
* Careful with casting call!
*/
System.out.println((int)(Math.random() * n);
All integers from [0,n)
**Suppose n is a correctly instantiated int variable—
* what is the range that this call will generate?
* Careful with casting call!
*/
System.out.println((int)(Math.random()) + n);
Every integers from [0 + n, 1 + n)
/**Suppose max and min are correctly instantiated int variables—
* what is the range that this call will generate?
*/
System.out.println((Math.random()*(max - min))(int) + min);
Every integers from [min, max)