Ejemplo n.º 1
0
 private void EqualsOperation(object sender, EventArgs e)
 {
     if (operation == "+")
     {
         _uppertablelayout.OutputTextBox.Text = (ArithmaticOperations.Add(value, double.Parse(_uppertablelayout.OutputTextBox.Text))).ToString();
     }
     else if (operation == "-")
     {
         _uppertablelayout.OutputTextBox.Text = (ArithmaticOperations.Subtract(value, double.Parse(_uppertablelayout.OutputTextBox.Text))).ToString();
     }
     else if (operation == "*")
     {
         _uppertablelayout.OutputTextBox.Text = (ArithmaticOperations.Multiply(value, double.Parse(_uppertablelayout.OutputTextBox.Text))).ToString();
     }
     else if (operation == "/")
     {
         _uppertablelayout.OutputTextBox.Text = (ArithmaticOperations.Divide(value, double.Parse(_uppertablelayout.OutputTextBox.Text))).ToString();
     }
     operator_pressed = false;
     value            = double.Parse(_uppertablelayout.OutputTextBox.Text);
     operation        = "";
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ArithmaticOperations Ar = new ArithmaticOperations();

            Console.Write("Enter a number: a");
            Ar.a = Convert.ToInt64(Console.ReadLine());

            Console.Write("Enter another number:b ");
            Ar.b = Convert.ToInt64(Console.ReadLine());

            Ar.c = Ar.add(Ar.a, Ar.b);
            Console.WriteLine("sum of " + Ar.a + " and " + Ar.b + " is " + Ar.c);
            Ar.c = Ar.sub(Ar.a, Ar.b);
            Console.WriteLine("sub of " + Ar.a + " and " + Ar.b + " is " + Ar.c);
            Ar.c = Ar.product(Ar.a, Ar.b);
            Console.WriteLine("product of " + Ar.a + " and " + Ar.b + " is " + Ar.c);
            Ar.c = Ar.divide(Ar.a, Ar.b);
            Console.WriteLine("div of " + Ar.a + " and " + Ar.b + " is " + Ar.c);
            Ar.c = Ar.modulo(Ar.a, Ar.b);
            Console.WriteLine("modulo of " + Ar.a + " and " + Ar.b + " is " + Ar.c);
            Console.ReadKey();
        }
        private void UnaryOperator_Click(object sender, System.EventArgs e)
        {
            if (textBox1.Text == "")
            {
                textBox1.Text = "0";
            }
            else
            {
                Button btn = (Button)sender;
                switch (btn.Text)
                {
                case "Sq. Rt.":
                    textBox1.Text = (ArithmaticOperations.SquareRoot(double.Parse(textBox1.Text))).ToString();
                    break;

                case "Log x":
                    textBox1.Text = (ScientificOperations.Log10(double.Parse(textBox1.Text))).ToString();
                    break;

                case "Ln x":
                    textBox1.Text = (ScientificOperations.Ln(double.Parse(textBox1.Text))).ToString();
                    break;

                case "1/x":
                    textBox1.Text = (ScientificOperations.Inverse(double.Parse(textBox1.Text))).ToString();
                    break;

                case "!":
                    textBox1.Text = (ScientificOperations.Factorial(int.Parse(textBox1.Text))).ToString();
                    break;

                case "+/-":
                    textBox1.Text = (ArithmaticOperations.PlusMinus(double.Parse(textBox1.Text))).ToString();
                    break;

                case "Sin":
                    textBox1.Text = (ScientificOperations.Sin(double.Parse(textBox1.Text))).ToString();
                    break;

                case "Cos":
                    textBox1.Text = (ScientificOperations.Cos(double.Parse(textBox1.Text))).ToString();
                    break;

                case "Tan":
                    textBox1.Text = (ScientificOperations.Tan(double.Parse(textBox1.Text))).ToString();
                    break;

                case "<-":
                    if (textBox1.Text.Length > 0)
                    {
                        int len = textBox1.Text.Length;
                        textBox1.Text = textBox1.Text.Substring(0, len - 1);
                    }
                    if (textBox1.Text == "")
                    {
                        textBox1.Text = "0";
                    }
                    break;
                }
            }
        }
Ejemplo n.º 4
0
 public double Calculate()
 {
     return(ArithmaticOperations.Subtract(_num1, _num2));
 }
Ejemplo n.º 5
0
 public double Calculate()
 {
     return(ArithmaticOperations.SquareRoot(_num));
 }
Ejemplo n.º 6
0
 public double Calculate()
 {
     return(ArithmaticOperations.PlusMinus(_num));
 }
Ejemplo n.º 7
0
 public double Calculate()
 {
     return(ArithmaticOperations.Divide(_num1, _num2));
 }
Ejemplo n.º 8
0
 public double Calculate()
 {
     return(ArithmaticOperations.Multiply(_num1, _num2));
 }