Ask Question
7 February, 02:42

How do I write: "get a random number between - 10 and 11 but it cannot be 0"? (java)

+3
Answers (1)
  1. 7 February, 04:19
    0
    generate a random number in a known range and map the result to the range you want

    Explanation:

    Use any of the usual methods to get a random number in the range 0-20, then subtract 9. Use an IF statement to test if the result is 0. If it is, replace the value with - 10.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How do I write: "get a random number between - 10 and 11 but it cannot be 0"? (java) ...” 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