Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+19 votes

Is there a code for us to choose randomly from a set of unrelated integers, like (0,2,3) perhaps ?

asked in CSC211_Winter2018 by (1 point)

1 Answer

+15 votes

One way to do this would make three int variables, assigned to each number. Then generate a random number from 1-3 using the Random object, and then use if/else statements to determine which number it would be. Though there may be a better way of going about this.

answered by (1 point)