Exemplo n.º 1
0
        private void equals_Click(object sender, EventArgs e)
        {
            double Result = 0;

            switch (sOperator)
            {
            case "+":
                Result = float.Parse(sFirstValue) + float.Parse(ResultText.Text);
                break;

            case "-":
                Result = float.Parse(sFirstValue) - float.Parse(ResultText.Text);
                break;

            case "*":
                Result = float.Parse(sFirstValue) * float.Parse(ResultText.Text);
                break;

            case "/":
                Result = float.Parse(sFirstValue) / float.Parse(ResultText.Text);
                break;

            case "sin":
                double val = double.Parse(sFirstValue);
                Result = Math.Sin(val * Math.PI / 180);

                break;

            case "cos":
                double ans = double.Parse(sFirstValue);
                Result = Math.Cos(ans * Math.PI / 180);
                break;

            case "tan":
                ans    = double.Parse(sFirstValue);
                Result = Math.Tan(ans * Math.PI / 180);
                break;

            case "fact":
                double fact  = 1;
                double value = double.Parse(sFirstValue);
                for (double i = value; i >= 1; i--)
                {
                    fact = fact * i;
                }
                Result = fact;
                break;

            case "square":
                Result = float.Parse(sFirstValue) * float.Parse(sFirstValue);
                break;
            }
            ResultText.ResetText();
            ResultText.Text = Convert.ToString(Result);
        }
Exemplo n.º 2
0
 private void clickAdd_Click(object sender, EventArgs e)
 {
     sFirstValue = ResultText.Text;
     ResultText.ResetText();
     sOperator = clickAdd.Text;
 }
Exemplo n.º 3
0
 private void divide_Click(object sender, EventArgs e)
 {
     sFirstValue = ResultText.Text;
     ResultText.ResetText();
     sOperator = divide.Text;
 }
Exemplo n.º 4
0
 private void tabButton_Click(object sender, EventArgs e)
 {
     sFirstValue = ResultText.Text;
     ResultText.ResetText();
     sOperator = tabButton.Text;
 }
Exemplo n.º 5
0
 private void subtract_Click(object sender, EventArgs e)
 {
     sFirstValue = ResultText.Text;
     ResultText.ResetText();
     sOperator = subtract.Text;
 }