I am seeking for some assistance in the Lottery program that suppose to generate 10,000 random numbers. I have two listbox which displays the random numbers. this is what is asking to do.

C# program that simulated a lottery game containing 3 digit numbers. This program was written as a Graphical User Interface application in Visual Studio .NET.

Your program generated multiple 3 digit random numbers and then counted how many times each 3 digit number appears.

Your Graphical user interface included:

A label that displays the 10 most common 3 digit numbers and the number of times it appeared

A label that displays the 10 least common 3 digit numbers and the number of times it appeared

A button that, when clicked, generates 10,000 random, 3 digit numbers and then populates the two labels mentioned above.

Your program also contained an array that kept track of the number of times each 3 digit value was generated

Your program contained a method that determines the 10 most common numbers

Your program contained a method that determines the 10 least common numbers

Can anyone please help?

public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnGenerate_Click(object sender, EventArgs e) { int n; int number; int count; int listBox; //Populate the array int[] lottery = new int[10000]; //initialize the array for (n = 0; n < 10000; n++) { lottery[n] = new Random().Next(-1, 10000); } //Sort the array Array.Sort(lottery); //Count the number of times each number is found in the array number = lottery[0]; count = 0; listBox = 1; for (n = 0; n < 10000; n++) { //if number is equal to the number in the current array position, increment count if (number == lottery[n]) { count++; } else { if (listBox == 1) { lstNumbers1.Items.Add(number + " " + count); listBox = 2; } else { lstNumbers2.Items.Add(number + " " + count); listBox = 1; } count = 0; number = lottery[n]; } } } } }

It renders the numbers 3 and 4 digits randomly with no errors.