Friday, March 11, 2011

Lotto Program in C#

Figure 1.

This is a little Lotto-Program which can maintenance you fill your lotto ticket. It is written in C#.NET 2.0 by using Visual Studio 2005.

Provided you race it testament present the 6 Lotto numbers in the 6 TextBoxes for everyone frame. Every bout you click "Next Frame" press-stud the numbers are displayed in unsorted form however by clicking the "Sort numbers" button they testament be then displayed sorted in the TextBoxes.

Figure 2.

As you can distinguish in the law provided the programme runs there is an algorithm that determines which 6 fortuitous numbers are stored in an array dawn from 1 to 49. The 6 casual numbers are in unsorted computation in Textboxes seeing whether you wristwatch the "Lotto Trail Fanfare" on the advisey the winning Lotto numbers blow in at the day one unsorted on the shade. And then the speaker repeats the winning Lotto numbers nevertheless this age in sorted establishment. So the "Sort numbers" button does the identical job as the speaker.

And last of all the in fashion hour and the numeral of everyone frame are displayed, very. It doesn't pick the winning numbers all the lifetime, it just shows you which numbers the most hour are selected randomly. The algorithm (got from internet years ago) is not the choicest for a know stuff lotto-application on the contrary I determine it is positive just for programming and amusing. 

privatevoid frmLotto_Load(object sender, EventArgs e)

    int[] stiff = new int[c];

    DateTime dt = new DateTime();

    dt = DateTime.Now;

    Random rnd = new Random(dt.Millisecond);

        numb[i] = rnd.Next(1, 50);

    Array.Sort(numb);

    int k = 0;

    int j = 0;

            result[k] = stiff[i];

            lottonumbers[k] = j += 1;

            k += 1;

            j = 0;

    Array.Sort(lottonumbers, completion);

    fnDisplay6NumbersUnsorted();

    DateTime dt1 = DateTime.Today;

    this.labelDaytime.Text = dt1.ToLongDateString();

    this.label4.Text = n_draw.ToString();


No comments:

Post a Comment