Write statements that assign random integers to the variable n in the following ranges.
Assume Random randomNumbers = new Random() has been defined and use the two-parameter version of the method Random.Next.
a) 1 ?n ?2
b) 1 ? n ? 100
c) 0 ? n ? 9
d) 1000 ? n ? 1112
e) –1 ? n ? 1
f) –3 ? n ? 11
a) n = randomNumbers.Next(1, 3);
b) n = randomNumbers.Next(1, 101);
c) n = randomNumbers.Next(0, 10);
d) n = randomNumbers.Next(1000, 1113);
e) n = randomNumbers.Next(-1, 2);
f) n = randomNumbers.Next(-3, 12);
You might also like to view...
The Draw Table command can be accessed from the:
A) Table button. B) Layout tab. C) Quick Tables button. D) Insert Table button.
________ is a method reference for an instance method that should be called on a specific object. It creates a one-parameter lambda that invokes the instance method on the specified object—passing the lambda’s argument to the instance method—and returns the method’s result.
a. Math::sqrt b. System.out::println c. TreeMap::new d. String::toUpperCase