Page 271 - AP Computer Science A, 7th edition
P. 271
statement
import static java.lang.Math.∗;
allows use of all Math methods and constants without the Math
prefix. Thus, the statement in formula 1 above could be written
radius = sqrt(area / PI);
Static imports are not part of the AP subset.
Random Numbers
RANDOM REALS The statement
double r = Math.random();
produces a random real number in the range 0.0 to 1.0, where 0.0 is included and 1.0 is not.
This range can be scaled and shifted. On the AP exam you will be expected to write algebraic expressions involving Math.random() that represent linear transformations of the original interval 0.0 ≤ x < 1.0.
Example 1
Produce a random real value x in the range 0.0 ≤ x < 6.0. double x = 6 ∗ Math.random();
Example 2
Produce a random real value x in the range 2.0 ≤ x < 3.0. double x = Math.random() + 2;