private void BSqrt_Click(object sender, RoutedEventArgs e) { if (number1 > 0) { result = Calculators.Root(number1); Resultbox.Text = $"sqrt({number1}) = {result}"; //this way you are ready to add the second number FullText.Text = $"sqrt({number1}) = {result}"; printed = true; } else { operation = "sqrt(0)"; //this also ensures that the else statements run for the num buttons Resultbox.Text = "sqrt(0)"; //this way you are ready to add the second number FullText.Text = "sqrt(0)"; } }
public void CorrectROOTResult(int a, int expected) { var result = Calculators.Root(a); Assert.AreEqual(expected, result); }
//Print Button private void BEqual_Click(object sender, RoutedEventArgs e) { if (printed == true) { } // if has been printed dont print again else if (operation == "+") { result = (Calculators.Add(number1, number2)); Resultbox.Text = result.ToString(); FullText.Text += $" {number2} = {result}"; } else if (operation == "-") { result = (Calculators.Subtract(number1, number2)); Resultbox.Text = result.ToString(); FullText.Text += $" {number2} = {result}"; } else if (operation == "*") { result = (Calculators.Multiply(number1, number2)); Resultbox.Text = result.ToString(); FullText.Text += $" {number2} = {result}"; } else if (operation == "/") { if (number2 == 0) { Resultbox.Text = "Cannot divide by 0"; //this way you are ready to add the second number } else { result = (Calculators.Divide(number1, number2)); Resultbox.Text = result.ToString(); FullText.Text += $" {number2} = {result}"; } } else if (operation == "%") { result = (Calculators.Modulus(number1, number2)); Resultbox.Text = result.ToString(); FullText.Text += $" {number2} = {result}"; } else if (operation == "^") { result = (Calculators.PowerOf(number1, number2)); Resultbox.Text = result.ToString(); FullText.Text += $" {number2} = {result}"; } else if (operation == "^ 2") { result = Calculators.PowerOfTwo(number1); Resultbox.Text = result.ToString(); FullText.Text += $" = {result}"; } else if (operation == "sqrt(0)") { result = Calculators.Root(number2); Resultbox.Text = $"sqrt({number2}) = {result}"; FullText.Text = $"sqrt({number2}) = {result}"; } printed = true; }