Ask Question
18 September, 06:20

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

+3
Answers (1)
  1. 18 September, 06:29
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers