4. Suppose you want to set the double variable oneToThree to a random real numbe
ID: 669896 • Letter: 4
Question
4. Suppose you want to set the double variable oneToThree to a random real number uniformly distributed in the interval [1.0, 3.0). You have made the following declaration: Random r = new Random1L(); noting that r.nextDouble() returns a random real number uniformly distributed in the interval [0.0, 1.0). Which statement will set oneToThree to the desired result?
A. * r.nextDouble(); B. + 2.0 * r.nextDouble(); C. + r.nextDouble() + r.nextDouble(); D. + r.nextDouble() + r.nextDouble();
Explanation / Answer
B will give the correct answer as A can give you zero and D can also give you zero adding double may produce something extra so C is eliminated
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.