[key] csa u4l5 random extra practice
[key] csa u4l5 random extra practice
double j = Math.random();
double k;
A. k = j + 0.75;
B. k = j + 0.75 * 4.0;
C. k = j * 4.0;
D. k = j * 4.0 + 0.75;
E. k = j * 4.75;
1
AP Exam Prep
/*
* Returns a 1D array of random int values between 0 and 100, inclusive
*/
public int[] createRandomNumbers() {
int[] tempNumbers = new int[10];
return tempNumbers;
}
Which line of code should replace /* missing code */ to produce the intended result?
2
Extra Practice
Do This: Using Math.random(), implement an algorithm for each of the following prompts.
Given 1D array of int values called nums, randomly shuffle the array. To shuffle, repeatedly swap the values of
two randomly selected elements of the array.
// to shuffle the array, this algorithm swaps randomly selected elements 100 times
for (int count = 0; count < 100; count++) {