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

Which of the following is a good question to ask yourself when determining whether readers will care about your thesis statement? A. So what? B. Why now? C. How
Wap to print sum of N - number​
The maximum heart rate for a 16 year old is?
*theology* What are 5 doubts you have about faith?
In the boxes below create examples of the different types of line. Label each one below its box.
How can you rewrite (z ≤ −1. 75) in order to find the answer?.
Which of the following allows a human to continue to grow?
The pair of figures to the right are similar. The area of one figure is given. Find the area of the other figure to the nearest whole number. Area of larger tri
Find sinx+cosx if sinx*cosx=3/8
19. A strategy to reduce resource use through decreased demand and increased efficiency is conservation recycling source reduction biodiversity