Write a program that simulates a basic lottery your user


Write a program that simulates a basic lottery.

Your user will "purchase" one lottery ticket. Each ticket will contain 5 unique numbers (numbers cannot be repeated within the ticket). Each number will be between 1 and 50, 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. Again, the ticket will contain 5 unique numbers (numbers cannot be repeated within the ticket) in the range 1 to 50 (inclusive). The winning lottery numbers should be stored in a separate array.

Here's the fun part - your program should continue to generate "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

The program should display the following:·

o The numbers in the user's ticket

o The winning lottery numbers when the win occurred

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

At the time of the win, the number of times each value 1-50 was generated for a winning lottery number should be written to a file. In addition, statements indicating which number(s) was generated most often and which number(s) was generated least often should be written to the file. You must validate all user input.

Numeri·c output should be displayed with commas.

Be aware that your program will run faster if you do not print out a lot of output. So, I recommend that you break this into small pieces and validate that each of the pieces works using output statements and then remove all but the final required output statements so that it will run faster.

The code should be written using efficient processing.·

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

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write a program that simulates a basic lottery your user
Reference No:- TGS01701729

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)