for one of my assignments I am trying to generate a random number between 16-26 (both inclusive). I've read around and tried different methods but for some reason it goes over the specified range. This is what I have at the moment:
int dealerHand = 16 + (int) (Math.random() * ((26 - 16) + 16));
Any idea on why this isn't working? Thanks!