Peace & Blessing family,
Here is my assignment from school. I think I did this code right. Still not sure though, but it did work. It did give me my .class file. My question is how do I repeat this process 7 more times. How do I do that with a loop, and where do I put the loop? Here is what I've done so far. I want to thank you all for your help on this project. Thank you family.
School Assignment:
A lottery requires that you select seven different numbers from the integers 1 to 35. A separate powerball number should also be generated. The powerball number should be within the range of 1-10. Write a
Java program that will do this for you and generate eight sets of seven numbers plus one powerball number. You must create an array and you must use the random() method in your solution. The solution must also include the use of at least one repetition statement.
Details:
For generating random numbers you can use the random() static method of class Math. It returns a double so you will need to cast it as an integer. If you set the range to 35, you can generate a random number between 1 and 35 through:
number = (int) ( range * Math.random() ) + 1;
Note that you need eight sets of numbers and in each set you have should have seven different numbers - plus a powerball number. There should not be duplicate numbers within each set of seven. Of course the same number can occur in multiple sets, but within the same set of 7 numbers it should only occur once, if at all.
Here is an example of a valid set of numbers: 5, 33, 3, 9, 22, 30, 15, 3
The first seven numbers must be unique and within the range of 1-35. The last number is the powerball number. The powerball number may be a duplicate and that is fine. It must range between 1-10.
Here is my code: