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?
			
			
									
									
						About Question com.enthuware.jfcja.v8.2.419 :
Moderator: admin
- 
				vugar.asadov
 - Posts: 1
 - Joined: Thu Dec 07, 2017 6:41 am
 - Contact:
 
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question com.enthuware.jfcja.v8.2.419 :
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).
			
			
									
									
						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).
Who is online
Users browsing this forum: No registered users and 5 guests