COMP 274 All Assignments COMP 274 All Assignments | Page 5
The Random class from the java.util package can also be used to get random numbers. The
nextInt method returns an integer from 0 up to but not including the argument value provided
to the nextInt method.
Random rand = new Random( );
int number = rand.nextInt(10); //results in an integer between 0 and 9
minimumValue + differenceBetweenValues * rand.nextInt(scalingFactor )
The formula shown above is used to generate a range of random numbers starting at some
minimum value and generating some specified number of random values. The scalingFactor
determines how many different random values will be generated by the call to nextInt, starting
with the value 0. The difference between values is usually 1.
Your final programming document should contain in the following order:
1. Screen capture of the first program followed by source code.
2. Screen capture of the second program followed by source code.
3. Submit this as the Week 1 Programming Solution.