2 we need to import the package explaining what the

Info icon This preview shows pages 16–23. Sign up to view the full content.

View Full Document Right Arrow Icon
System.out.println(value2); (2)? We need to IMPORT the package “explaining” what the class Random is! What might the following code print? A. 10 and 1.0 B. 1 and 2.0 C. 8 and 0.5 D. 8.5 and 0.5 E. More than one of these are possible
Image of page 16

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Random Numbers import java.util.Random; // declare a generator for random numbers Random generator = new Random(); // generate an int between 0 and 10, not including 10 int value1 = generator.nextInt(10); // generate a double between 0.0 and 1.0, not including 1.0 double value2 = generator.nextDouble(); System.out.println(value1); 5 // one possible value System.out.println(value2); 0.42 // one possible value What do you think the following code prints?
Image of page 17