public void CanAddIntAndDecimal() { var firstNumber = 3; var secondNumber = 5.5m; var result = BasicMath.Addition(firstNumber, secondNumber); Assert.AreEqual(result, 8.5m); }
public void CanAddFloatAndDouble() { var firstNumber = 3.3f; var secondNumber = 5.5; var result = BasicMath.Addition(firstNumber, secondNumber); Assert.AreEqual(result, 8.8); }
public void CanAddIntegers() { var firstNumber = 3; var secondNumber = 5; var result = BasicMath.Addition(firstNumber, secondNumber); Assert.AreEqual(result, 8); }
protected void GetAddition() { // call the getNumbers method and pass //it the min, max, and operator GetNumbers(0, 100, "+"); //get the answer from the class answer = m.Addition(); //store it in a session variable Session["answer"] = answer; }
private void BtnEquals_Click(object sender, EventArgs e) { /*depending on the last button to be clicked perform the correct operation * and output the result to the user */ if (!(multiplyButtonClicked && minusButtonClicked && plusButtonClicked && divisionButtonClicked) && CheckForInput(tbResult.Text)) { total = double.Parse(tbResult.Text); } if (!double.TryParse(tbResult.Text, out double lastInput)) { return; } if (plusButtonClicked) { total = BasicMath.Addition(valueHolder, lastInput); } else if (minusButtonClicked) { total = BasicMath.Subtraction(valueHolder, lastInput); } else if (multiplyButtonClicked) { total = BasicMath.Multiplication(valueHolder, lastInput); } else if (divisionButtonClicked) { if (BasicMath.Division(valueHolder, lastInput, out double setTotal)) { total = setTotal; } else { MessageBox.Show("Error: Cannot Divide By Zero"); return; } } //print result tbResult.Text = $"{total}"; //reset calculator valueHolder = 0; total = 0; isTotal = true; plusButtonClicked = minusButtonClicked = divisionButtonClicked = multiplyButtonClicked = false; }
private void BtnPlus_Click(object sender, EventArgs e) { //if there is input in the textbox add input to valueHolder if (CheckForInput(tbResult.Text)) { valueHolder = BasicMath.Addition(valueHolder, double.Parse(tbResult.Text)); tbResult.Clear(); plusButtonClicked = true; minusButtonClicked = false; divisionButtonClicked = false; multiplyButtonClicked = false; } else { MessageBox.Show("Please enter valid input"); } }