Exercise 08: Lotto and ...
This week’s lab work is intended give you practice using the Random class.
Pre-Lab
Please bring these exercises printed out or written out with you to lab. Please have your name on your page.
P1. How do you generate random numbers between 1 and 10 with Java? In what package is the library?
P2. How do you define an array that can count how often the numbers between 1 and 10 are generated? We call this a frequency table.
P3. Where can you find information about the lotto numbers that have been picked in Germany on the Internet?
P4. Where can you find information about javadoc on the Internet?
Post-Lab, AKA What To Turn In
- pdf: the lab report, including a table with your frequencies for the Lotto numbers picked.
- zip: the final version of your Lotto code, properly and thoroughly documented with javadoc.
Lab assignments are due on thursday at 22:00.
Assignment
Lotto
- Create a class that will be doing some testing of random numbers. Make a method that picks the six numbers for next Saturday between 1 and 49. Note that no two numbers may be the same! How do you avoid this?
- Expand the method to count how often each number is picked.
- Now pick the 6 lotto numbers 1000 times. Print out the frequencies.
- Repeat for 10,000 times. And 100,000 times. And 1,000,000 times. Put your results in a nice table and include it in your report.