Chaspen9005 Chaspen9005
  • 14-07-2019
  • Computers and Technology
contestada

What is the value of "d" after this line of code has been executed? double d = Math.round ( 2.5 + Math.random() ); A. 2 B. 3 C. 4 D. 2.5

Respuesta :

PhantomWisdom PhantomWisdom
  • 16-07-2019

Answer:

  3

Explanation:

Math.random() is the function which gives the value greater than or equal to 0.0 and less than 1.0. it gives the double type value.

Math.round is also the function which gives the closest long to the argument.

for example:

Math.round(2.5) it gives 3.

so, Math.random() generate number 0.000 to 0.999

maximum possible value inside the Math.round(2.5+0.999) which is equal to

Math.round(3.499) which gives 3 not 4 when it 3.5 then it gives 4.

therefore, the result is 3

Answer Link

Otras preguntas

¿LL o Y? bote__a Rewrite the word above using correct spelling
Multiply. Express your answer in standard form.(x^2-4x+3)(-3x^2+7x-1)
Please select the word from the list that best fits the definition ocean current that cools the West Coast of the United States
Explain how you can find a fraction that is equivalent to 1/4​
42x5y4=(-7x3y)(B) B =
Ke Guiwen is visiting the United States from China. As he visits several companies and talks to both workers and managers, he is surprised to realize that altho
Which structures allow the flow of carbon dioxide into a plant?
Anvi designs a game in which a player either wins or loses 4 points during each turn. Which equation represents all numbers of points(p), a player may have afte
under the full faith and credit clause of the constitution a state must.
What is the speed limit when traveling across a blind railroad crossing