ridhn26
ridhn26 ridhn26
  • 07-06-2020
  • Computers and Technology
contestada

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

Respuesta :

sqdancefan
sqdancefan sqdancefan
  • 07-06-2020

Answer:

  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.

Answer Link

Otras preguntas

A graph includes the ordered pair (2, 4). Write two different rules that would be possible for this graph. Explain how you found your answer
failure to maintain homeostasis results in
what percent of 35 is 28
Please can anyone help with this one? I 3y - 4 I = I 3y + 8 I
The volume of the sun is 1.4*10(18)cubic kilometers and the volume of the earth is 1.1*10(12)Cubic kilometers. About how many earths could fit into the sun?
Are harp seals affected by tides, currents, and waves?
Summarize the views regarding U.S. imperialism
Simply the expression : z2-z(z+3)+3z
what do you call a flowers colorful special leaves?
How does deposition change Earth's surface?