All pastes #795747 Raw Edit

Someone

public text v1 · immutable
#795747 ·published 2007-11-24 12:17 UTC
rendered paste body
private void button1_Click(object sender, EventArgs e)
        {
            //string str;
            double c, p, a, tl, d, avg, max, min, sum;
            int[] error = new int[5];
            c = p = a = tl = d = avg = max = min = sum = 0;
            for(int i=0;i<5;i++)
                error[i]=0;

            try
            {
                c = Convert.ToDouble(cbox.Text);           
            }
            catch 
            {
                error[0] = 1;
            }
            try
            {
                p = Convert.ToDouble(pbox.Text);
            }
            catch
            {
                error[1] = 1;
            }
            try
            {
                a = Convert.ToDouble(abox.Text);
            }
            catch
            {
                error[2] = 1;
            }
            try
            {
                tl = Convert.ToDouble(tlbox.Text);
            }
            catch
            {
                error[3] = 1;
            }
            try
            {
                d = Convert.ToDouble(dbox.Text);
            }
            catch
            {
                error[4] = 1;
            }

            for (int i = 0; i < 5; i++)
            {
                sum+=error[i];
                if(error[i] == 1)
                    MessageBox.Show("Lathos timi sto " + (i+1).ToString() + "o pedio");
            }

            if(sum == 0)
            {
                avg = (c + p + a + tl + d) / 5;
                max = c;
                if(p > max)
                    max = p;
                if(a > max)
                    max = a;
                if(tl > max)    
                    max = tl;
                if(d > max)
                    max = d;

                min = c;
                if(p < min)
                    min = p;
                if(a < min)
                    min = a;
                if(tl < min)
                    min = tl;
                if(d < min)
                    min = d;
                //str = "Max: " + max.ToString() + "\nMin: " + min.ToString() + "\nAvg: " + avg.ToString();
                //MessageBox.Show(str);
                maxlbl.Visible = true;
                minlbl.Visible = true;
                avglbl.Visible = true;
                rmaxlbl.Text = max.ToString();
                rminlbl.Text = min.ToString();
                ravglbl.Text = avg.ToString();
            }