Computer Science, asked by Ajin9012, 1 year ago

Which of the following options is the best for generating random integer 0 or 1?
A.(int)Math.random()
B.(int)Math.random() + 1
C.(int)(Math.random() + 0.5)
D.(int)(Math.random() + 0.2)

Answers

Answered by choudhary21
2
✔✔{\texttt{Answer}}✔✔
⤵⤵⤵⤵⤵⤵⤵⤵⤵⤵⤵ ıllıllıllıllıllıllııllıllıllıllıllıllııllıllıllıllıllıllı
_______________________

<b>Typing -

C.(int)(Math.random() + 0.5)✔✔✔

You could use boolean values of 0 or 1 based on value of A better result would be to declare java.util. want a " 0 or 1" answer, your range is 2 different integers.


\huge\boxed{\texttt{\fcolorbox{aqua}{grey}{C}}}

_______________________ ıllıllıllıllıllıllııllıllıllıllıllıllııllıllıllıllıllıllı

<b><big>⭐⭐Hope help You⭐⭐

Answer - By Choudhary21
Answered by Anonymous
3
Heya Buddy here is ur answer ⏭️⏭️⏭️⏭️

⭕ A. (int)Math.random() ❌❌

⭕(int)Math.random()+1 ❌❌

⭕(int)Math.random()+0.5 ✔️✔️

⭕(int)Math.random()+0.2 ❌❌

⭕ HOPE IT HELPS ⭕

⭐ By cute Einstein ⭐
Similar questions