A random number generator can be used to generate values 0 to N-1 when used with nextInt(N).
This program will use the random number generator to generate values between 1 and 12, representing months of the year.
Start with the supplied code template, editing the @author tag to include your full name.
The code already contains prompts for reading a seed for creating an instance of the random number generator and the number of times
to generate a random month.
Note that for reproducibility needed for auto-grading, the program will seed the random number generator with the given input value.
In a real program, you would seed with the current time (or use no seed to default to the current time), so that every program's output would
be different, which is what is desired, but can't be auto-graded.
Extend the code to simulate generating a random month a fixed number of times.
The output will be the month name corresponding to each random month number generated, displayed by accessing the month index
within the MONTH_NAMES array.
Note: A common student mistake is to create an instance of Random before each call to rand.nextInt().
But seeding should only be done once, at the start of the program, after which rand.nextInt() can be called any number of times.
Example:
Enter seed to start random number generator with:
5
How many random months should be generated?
3
December
May
March
Warning: If your program displays "invalid" or generates an ArrayOutOf BoundsException, you did not generate the random numbers
correctly.