Ask Question
23 April, 14:07

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

+2
Answers (1)
  1. 23 April, 17:27
    0
    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
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “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 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers