public void addCalculator_Test(double a, double b, double c) { //Arrange //Act uut.Add(a, b); //Assert Assert.That(uut.Add(a, b), Is.EqualTo(c)); }
private double Calculate(string input, string input2) //executes when '=' is pressed { if (addition) { total = Calc.Add(input, input2); addition = false; } else if (subtraction) { total = Calc.Subtract(input, input2); subtraction = false; } else if (multiplication) { total = Calc.Multiply(input, input2); multiplication = false; } else if (division) { total = Calc.Divide(input, input2); division = false; } outputLabel.Text = total.ToString(); return(total); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Calc c = new Calc(); Console.Write(c.Add(2, 3)); }
private void BtnEqual_Click(object sender, RoutedEventArgs e) { Result = ""; switch (Sign) { case "+": Result = Calc.Add(Convert.ToDouble(First), Convert.ToDouble(Second)).ToString(); break; case "-": Result = Calc.Subtract(Convert.ToDouble(First), Convert.ToDouble(Second)).ToString(); break; case "x": Result = Calc.Multiply(Convert.ToDouble(First), Convert.ToDouble(Second)).ToString(); break; case "/": Result = Calc.Divide(Convert.ToDouble(First), Convert.ToDouble(Second)).ToString(); break; } First = Result; FirstOperation = true; Second = ""; }
//todo: change from recursion to iteration public double ChooseMethod() { string caseSwitch = UI.getMethodChoise(); switch (caseSwitch) { case "Add": return(calc.Add()); case "Subtract": return(calc.Subtract()); case "Multiply": return(calc.Multiply()); case "Divide": return(calc.Divide()); case "Exponential": return(calc.Exponent()); case "Adam": return(9001); default: Console.WriteLine("Enter Valid Method to Choose"); return(ChooseMethod()); } }
public static int Main(string[] args) { Calc c = new Calc(); int ans = c.Add(10, 84); Console.WriteLine("10 + 84 is {0}.", ans); return(0); }
static void Main() { Calc c = new Calc(); int ans = c.Add(10, 84); Console.WriteLine("10 + 84 = {0}", ans); Console.ReadLine(); }
public void Testadditionmethod() { //arrange var calc = new Calc(); var result = calc.Add(2, 4); //Assert Assert.AreEqual(6, result); }
static void Main(string[] args) { Calc c = new Calc(); int a = 10, b = 84; Console.WriteLine("{0} + {1} is {2}.", a, b, c.Add(a, b)); Console.ReadLine(); }
static void Main(string[] args) { Calc test = new Calc(); Console.WriteLine(test.Add(2, 2)); Console.WriteLine(test.Sub(4, 2)); Console.WriteLine(test.Multi(3, 3)); Console.WriteLine(test.Power(3, 3)); Console.WriteLine(test.Sqrt(9)); }
static void Main(string[] args) { Calc c = new Calc(); int ans = c.Add(10, 84); Console.WriteLine("10 + 84 is {0}.", ans); // Wait for user to press the Enter key before shutting down. Console.ReadLine(); }
public void TestAdditionMethod() { //arranges the method var calc = new Calc(); //shows the action var result = calc.Add(2, 4); //Assert Assert.AreEqual(6, result); }
static void Main(string[] args) { Calc calc = new Calc(); Console.WriteLine($"3+5={calc.Add(3, 5)}"); Console.WriteLine($"3-5={calc.Sub(3, 5)}"); Console.WriteLine($"3*5={calc.Mul(3, 5)}"); Console.WriteLine($"3/5={calc.Div(3, 5)}"); Console.ReadKey(); }
private void buttonMPlus_Click(object sender, EventArgs e) { try { mr = Calc.Add(mr, Convert.ToDouble(textBoxResult.Text)); } catch (Exception ex) { textBoxException.Text = ex.Message; } }
private void equalClick(object sender, RoutedEventArgs e) { try { //See which operator was used and perform the calculation if (calculator.Check(calculator.isPlus)) { calculator.secondNumber = double.Parse(resultBox.Text); calculator.answer = calculator.Add(); showAndSetAnswer(sender, e); } else if (calculator.Check(calculator.isMinus)) { calculator.secondNumber = double.Parse(resultBox.Text); calculator.answer = calculator.Subtract(); showAndSetAnswer(sender, e); } else if (calculator.Check(calculator.isMult)) { calculator.secondNumber = double.Parse(resultBox.Text); calculator.answer = calculator.Multiply(); showAndSetAnswer(sender, e); } else if (calculator.Check(calculator.isDiv)) { calculator.secondNumber = double.Parse(resultBox.Text); if (calculator.secondNumber == 0) { throw new DivideByZeroException(); } calculator.answer = calculator.Divide(); showAndSetAnswer(sender, e); } else if (calculator.Check(calculator.isExp)) { calculator.secondNumber = double.Parse(resultBox.Text); calculator.answer = calculator.Exponentiate(); showAndSetAnswer(sender, e); } } catch (DivideByZeroException) { resultBox.Text = "Cannot Divide by Zero"; clearAll(); } catch (FormatException) { resultBox.Text = resultBox.Text; clearAll(); } }
static void Main(string[] args) { Calc calculator = new Calc(); double test1 = calculator.Add(4, 4); double test2 = calculator.Subtract(10, 4); double test3 = calculator.Multiply(6, 7); double test4 = calculator.Power(2, 5); Console.WriteLine("Test 1: 8 = " + test1); Console.WriteLine("Test 2: 6 = " + test2); Console.WriteLine("Test 3: 42 = " + test3); Console.WriteLine("Test 4: 32 = " + test4); Console.ReadKey(); }
static void Main(string[] args) { Calc calc = new Calc(); Console.WriteLine(calc.Add(3, 2)); Console.WriteLine(calc.Pow(100, 0)); EngineerCalc engineerCalc = new EngineerCalc(); Console.WriteLine(engineerCalc.Tan(180)); Console.WriteLine(engineerCalc.GetCubeRoot(27)); Console.WriteLine(calc.GetRoot(4)); Console.WriteLine(calc.GetInvalidRoot(3)); }
private void KeysAdd() { cl += 1; d += 1; eq = 0; if (ck > 0) { //Calc.Add(Calc.Operand1, "+"); Calc.Add(Calc.Operand1); txtOutput.Text = ""; if (!(Showsmb > 0)) { KeyResult('+'); } } else if (empty(txtOutput, "Operand 1")) { if (validate.check(txtOutput.Text)) { decimal op1 = decimal.Parse(txtOutput.Text); // Calc.Add(op1, "+"); Calc.Add(op1); txtOutput.Text = ""; if (!(Showsmb > 0)) { KeyResult('+'); } ck += 1; } else { d = 0; MessageBox.Show("Please enter a valid input"); txtOutput.Focus(); } } else { d = 0; txtOutput.Focus(); } }
private static void ShowCalcResult(double number1, double number2, string calcOperator) { Calc calc = new Calc(); if (calcOperator == "+") { Console.WriteLine($"{number1} {calcOperator} {number2} = {calc.Add(number1, number2)}"); } else if (calcOperator == "-") { Console.WriteLine($"{number1} {calcOperator} {number2} = {calc.Subtract(number1, number2)}"); } else if (calcOperator == "*") { Console.WriteLine($"{number1} {calcOperator} {number2} = {calc.Multiply(number1, number2)}"); } else if (calcOperator == "/") { Console.WriteLine($"{number1} {calcOperator} {number2} = {calc.Divide(number1, number2)}"); } }