Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

AaBbCcDc AaBbCcD AaBbC AaBbCcl 5-2:B- 11 Normal 1 NoSpac Headingl Heading 2 !, a

ID: 3585543 • Letter: A

Question

AaBbCcDc AaBbCcD AaBbC AaBbCcl 5-2:B- 11 Normal 1 NoSpac Headingl Heading 2 !, atKx, x' A··A- AaBbCcE AaBbCcD Title Subtitle Subtle En. Font Paragraph Styles public float nextFloato Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random aumber generator's sequence. Given a Random object named gea, what range of values are produced by the following expressions? a) gon.nextiat25) from 0 to 24 b) gen.aextlat 6+1 from 1 to 6 c) gen nextlnt(100) 10 from 10 to 109 d) gen nextlnt(50) 100 from e) gen nextlnt(10)-5 2 aen.nextint(22)+ 12 Write an expression that produces a random integer in the following ranges

Explanation / Answer

The nextInt() function of the given Random object named gen generates random number from 0 - (x-1) where x is the input argument.

So gen.nextInt(x) will produce random numbers from 0 - (x-1)

d) gen.nextInt(50) + 100:

This expression will generate random numbers between the range ( 0 + 100 , 50 -1 +100) = ( 100 , 149 )

e) gen.nextInt(10) - 5:

This expression will generate random numbers between the range ( 0 -5 , 10 -1 -5) = ( -5, 4 )

f) gen.nextInt(22) + 12:

This expression will generate random numbers between the range ( 0 + 12, 22 -1 + 12) = ( 12 , 33 )