Esempio n. 1
0
        private static void StartWithOperator(Calculator calculator, string input)
        {
            double firstNumber = double.Parse(Console.ReadLine());

            switch (input)
            {
            case "+":
                calculator.Add(firstNumber);
                break;

            case "-":
                calculator.Subtract(firstNumber);
                break;

            case "*":
                calculator.Multiply(firstNumber);
                break;

            case "/":
                calculator.Division(firstNumber);
                break;
            }

            Console.WriteLine($"The result is: {calculator.FinalResult()}");
        }
Esempio n. 2
0
        private void divisionButton_Click(object sender, EventArgs e)
        {
            calculator.FirstNumber  = Convert.ToDouble(firstNumberTextBox.Text);
            calculator.SecondNumber = Convert.ToDouble(secondNumberTextBox.Text);

            resultTextBox.Text = calculator.Division().ToString();
        }
Esempio n. 3
0
        private static void NumberProcessing(Calculator calculator, string input)
        {
            calculator.Clear();

            double firstNum  = double.Parse(input);
            string operation = Console.ReadLine();
            double secondNum = double.Parse(Console.ReadLine());

            switch (operation)
            {
            case "+":
                calculator.Add(firstNum, secondNum);
                break;

            case "-":
                calculator.Subtract(firstNum, secondNum);
                break;

            case "*":
                calculator.Multiply(firstNum, secondNum);
                break;

            case "/":
                calculator.Division(firstNum, secondNum);
                break;
            }

            Console.WriteLine($"The result is: {calculator.FinalResult()}");
        }