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

8) What percent of 38 is 15
HELP ILL GIVE YOU BRAINLIEST IF YOUR RIGHT ‼️‼️‼️‼️
what is the slope of the line that contains the points (-2,8) and (-2,1)
what is sexual harras means​
What is the scale factor of AABC to A DEF?
Write one paragraph evaluating the effectiveness of Franklin D. Roosevelt’s speech following the attack on Pearl Harbor. Cite examples from the speech to suppor
Derek was doing his homework on his computer one night when he saw an ad banner for a free Playstation 9000. He clicked on the ad with great interest and was t
Given that 3m=2c-5k,express c in terms of k and m.
Select the correct answer. A school bus has 25 seats, with 5 rows of 5 seats. 15 students from the first grade and 5 students from the second grade travel in th
find the area of the shape below