vendredi 12 juin 2020

Generate a random number in Java between -100 and +100 [duplicate]

I have been working on a beginner program that's supposed to randomly generate a few numbers for the variables i assign them to. Method i need to use is the java 'Math.random()' method. I have looked for some guidance here before but never asked a question myself. The answer i found were too specific and used the question askers' variables or method names and i couldn't glean the right information. I have gotten to the point where i can generate a number but my range is either all positive or all negative and i need the overall range to be between -100 and +100. Can anyone help me out with a general example?




Aucun commentaire:

Enregistrer un commentaire