Welcome to the CSC Q&A.
Get help and give help!
Write great code!
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 (8 points)

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 (8 points)