예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Stat       clsStat = new Stat();
            TestNumber tstNum  = new TestNumber();
            AddMax     AM      = new AddMax();

            try
            {
                string x = textBox2.Text;

                string max;
                int    n = Convert.ToInt16(textBox2.Text);
                if (tstNum.test(n))
                {
                    int[] arrlist = AM.generate(n);
                    max = Convert.ToString(clsStat.addMax(arrlist));
                    MessageBox.Show("The maximum value for the list is: " + max);
                }
                else
                {
                    MessageBox.Show("Please choose a number between 5 and 20");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (tstNum.test(Convert.ToInt16(txt1.Text)))
         {
             stt.numGen(Convert.ToInt16(txt1.Text));
         }
         else
         {
             MessageBox.Show(" Skies die getal is nie tussen 5 en 20 nie");
         }
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void btnGetAverage_Click(object sender, EventArgs e)
        {
            int  amountNums = Convert.ToInt32(txtNum.Text);
            Stat numGen     = new Stat();

            TestNumber tester = new TestNumber();

            if (tester.test(amountNums) == true)
            {
                MessageBox.Show("The average of " + txtNum.Text + " numbers is: " + numGen.randomAvg(amountNums));
            }

            else
            {
                MessageBox.Show("Number out off bounds");
            }
        }
예제 #4
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            clsMedian  cls     = new clsMedian();
            Stat       clsStat = new Stat();
            string     list    = "";
            string     median;
            TestNumber tn = new TestNumber();

            try
            {
                string x = textBox1.Text;



                int n = Convert.ToInt16(textBox1.Text);
                if (tn.test(n))
                {
                    int[] arrlist = cls.generate(n);

                    for (int i = 0; i < n; i++)
                    {
                        list += arrlist[i] + "\r\n";
                    }

                    median = Convert.ToString(clsStat.calcMedian(arrlist));

                    MessageBox.Show("The list is: \r\n" + list + "\r\n The median is " + median);
                }
                else
                {
                    MessageBox.Show("Choose a number between 5 and 20");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }