Page 1 of 1

About Question com.enthuware.jfcja.v8.2.419 :

Posted: Sat Oct 02, 2021 1:21 pm
by vugar.asadov
1 + Math.round(Math.random()*9) will return a random number between 1 and 10.

Math.random()*9 will return a double between 0.0 to less than 9.0. Rounding it will give you a range of 0.0 to 10.0 (both inclusive). Adding 1 to it will give you a range of 1.0 to 11.0 (both inclusive).

the option says that expression will return random number between 1 and 10, but explanation says that it will give a you a range of 1.0 to 11.0 (both inclusive). so why this option is correct statement?

Re: About Question com.enthuware.jfcja.v8.2.419 :

Posted: Sat Oct 02, 2021 7:09 pm
by admin
The option is correct but the explanation is incorrect. It should say:
Rounding it will give you a range of 0.0 to 9.0 (both inclusive). Adding 1 to it will give you a range of 1.0 to 10.0 (both inclusive).