Your user will purchase one lottery ticket each ticket will


please code in Java

Write a program that simulates a basic lottery.

Your user will "purchase" one lottery ticket. Each ticket will contain 5 numbers. Each number will be between 1 and 20, inclusive.

You will allow the user to select their own numbers for their ticket or to have the computer randomly select the numbers.

You should represent the "ticket" using an array. Once the ticket has been purchased, your program will randomly generate the "winning lottery numbers" and determine if the user has won. The winning lottery numbers should be stored in a separate array.

Here's the fun part - your program should continue to generate a full set of "winning lottery numbers" drawings until your user wins the lottery. Your program will count the number of lottery drawings it takes to win.

A few things to consider:

The program should contain the following methods

o A main method o A method that determines the user's ticket numbers

o A method that determines the winning lottery numbers

o A method that determines if the user has a winning ticket

o A method that displays the following to the screen:

A message indicating the win ? The numbers in the user's ticket when the win occurred 

The winning lottery ticket numbers 

The number of times it took to get a match with a winning ticket 

The number of times each value 1-20 was generated for a winning lottery ticket 

The number(s) generated most often for the winning lottery tickets during this run of the program

The following should also be written to a file:

o The number of times each value 1-20 was generated for a winning lottery number

o The number(s) generated most often for the winning lottery tickets during this run of the program

For the sake of simplicity, you should implement your code to prevent duplicate values in the lottery tickets (ie - a specific number should only appear one time in any ticket).

You will need to write code to ensure the user doesn't select the same number twice and that the computer doesn't generate the same number twice.

The numbers do not have to match in order. For example, a user ticket with numbers 1, 2, 3, 4, 5 should be considered a match if the winning ticket numbers are 5, 2, 1, 3, 4.

You must validate all user input. 

Numeric output should be displayed with commas

The code should be written using efficient processing.

Remember to use good programming practices (comments, naming conventions, program structure, etc)

please use java

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Your user will purchase one lottery ticket each ticket will
Reference No:- TGS02888587

Expected delivery within 24 Hours