Question: Write a program that generates lottery numbers. Use the Random class to generate pseudorandom numbers. Use the nextInt() method of the Random class. Use the

Write a program that generates lottery numbers.

Use the Random class to generate pseudorandom numbers.

Use the nextInt() method of the Random class.

Use the following requirements to guide the code:

Use a nested loop structure in your code.

Your program should instantiate the Random class using this syntax:

Random numberGenerator = new Random();

Your program should prompt the user for the number of people for whom lottery numbers should be generated.

For each person, the program should generate:

3 numbers for the pick 3 lotto game

4 numbers for the pick 4 lotto game and

6 numbers for the pick 6 lotto game

Each call to the method: int r = rand.nextInt(9); will generate one lotto value between 0 and 9 (inclusive).

As the numbers are chosen, they should be displayed to the screen immediately.

In order to format the output correctly, you will need to print a few blank spaces after the third and seventh number generated, as well as and new line character after the thirteenth number generated for each person. (HINT: How can you use a conditional statement to determine whether you have just completed printing the last Pick 3, Pick 4 or Pick 6 lottery number?)

the format is below

Write a program that generates lottery numbers. Use the Random class togenerate pseudorandom numbers. Use the nextInt() method of the Random class. Use

For how many people would you like to generate lottery numbers? 2 Your lucky lottery numbers for the day are: Pick 3 Pick 4 Pick 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!