Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Shouldn't rand.nextInt(11) return a value between 0 and 10 inclusive?

+7 votes
I know this is, word-for-word, problem 5.6 on PracticeIt, but I'm actually baffled. If you have rand.nextInt(max), it's supposed to return values between 0 (inclusive) and max (exclusive), right? Or, rather, between 0 inclusive and (max - 1) inclusive?
asked Jan 27, 2015 in (Winter 14) by Nicholas Misner (100 points)

2 Answers

+5 votes
You are correct.  The practiceit website doesn't accept a semicolon in the answer, strangely.
answered Jan 27, 2015 by Kevin Barbian (100 points)
+1 vote
This question is actually a duplicate of:  http://lovelace.augustana.edu/q2a/index.php/296/on-self-check-5-6-i-put-rand-nextint-11-but-it-says-i-failed-why?show=296#q296

Note that if you would have searched for self check 5.6 on the Q&A, you could have found this answer yourself!
answered Jan 27, 2015 by Forrest Stonedahl (100 points)