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

How can I simpliy |-15| + |-26|?
In general, you would expect the platform of a political party to A. determine the outcome of a general election. B. consist of party leaders called planks. C.
The first interaction between Kumalo and Arthur Jarvis’s son leads to..? a. milk being sent to Ndotsheni by James Jarvis for the small children of the v
What is the ratio 175/250 written in word form and in lowest terms? A. 3 to 5 B. 2 to 5 C. 7 to 25 D. 7 to 10
What is the ratio 15 : 75 in lowest terms? A. 1 : 5 B. 2 : 5 C. 1 : 4 D. 3 : 5
Estimate the quotient. 103,981.81 ÷ 8.122 A. 12,500 B. 1,250 C. 125 D. 12.5
Can someone briefly summarize the trojan war about what happened between the goddess and the golden apple? EMERGENCY!
in 1919, Germany signed the Treaty of Versailles. Did the treaty reflect Wilson’s vision of “peace without victory”? Why or why not?
2x+y=5 and x+2y=4 Graph system of equation
Which is an equation in point-slope form for the given point and slope? Point: (1, –7); Slope: A. y-7=-2/3(x+1) B. y-7=2/3(x-1) C. y+7=-2/3(x-1)