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

FOR BRAINLIEST!!!!ASAP 19) One number is 9 more than another. Their product is 11 more than five times their sum. Find the numbers.
Solve the following equation for the given variable. 4x + 19 + 3x = -5 Round your answers to the nearest tenths place.
Help on 36 and 37 pls, the choices for 37 are 70,77,82, and 90
hi hello, could i get some help? please and thank you.
Help!!! Simplify each expression
d is the same as k less than 372 (How can I write this as an equation) I thought it would be d=k-372
You are living far from your family and you feel homesick. You will describe your family. You should say: 1/ Your homesickness 2/ Your family members (their ag
how is asking questions develop ideas?​
The exchange rate between dollars ($) and pounds (£) is $1 = £0.65 . The exchange rate between euros (€) and pounds is €1 = £0.74 . Khan changes €520 into pound
What is a frontier? a. a territory that has just been settled b. an area of rich farmland c. a boundary line between settled and unsettled lands d. a row of nav