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

"Find the point of intersection for each system of linear equations. Which method did you use & why?"
"Find the point of intersection for each system of linear equations. Which method did you use & why?"
Why was white America so fascinated by Harlem in the 1920s
A high-speed computer printer prints a page in 1/6 second. Using this printer, how long would it take to print 30 pages?
The Nile river flows into the Mediterranean Sea, what is the volume of the Nile River?:)
660 ft/min=_________ft/s 1 min = 60 sec
660 ft/min=_________ft/s 1 min = 60 sec
"Find the point of intersection for each system of linear equations. Which method did you use & why?"
Why was white America so fascinated by Harlem in the 1920s
I need help with piecewise functions. How to find the domain and range and how to write it notation.