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
2
✔✔✔✔
⤵⤵⤵⤵⤵⤵⤵⤵⤵⤵⤵ ıllıllıllıllıllıllııllıllıllıllıllıllııllıllıllıllıllıllı
_______________________
↪ -
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.
_______________________ ıllıllıllıllıllıllııllıllıllıllıllıllııllıllıllıllıllıllı
Answer - By Choudhary21
⤵⤵⤵⤵⤵⤵⤵⤵⤵⤵⤵ ıllıllıllıllıllıllııllıllıllıllıllıllııllıllıllıllıllıllı
_______________________
↪ -
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.
_______________________ ıllıllıllıllıllıllııllıllıllıllıllıllııllıllıllıllıllıllı
Answer - By Choudhary21
Answered by
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 ⭐
⭕ 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
Hindi,
7 months ago
Computer Science,
7 months ago
Computer Science,
7 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago
Science,
1 year ago