Ejemplo n.º 1
0
 protected void btnSubtract_Click(object sender, EventArgs e)
 {
     try
     {
         CalculatorClass calc = new CalculatorClass();
         calc.Num1 = double.Parse(txbNum1.Text);
         calc.Num2 = double.Parse(txbNum2.Text);
         lblAnswer.Text = calc.Difference.ToString();
     }
     catch (FormatException)
     {
         lblAnswer.Text = "Please enter numbers only!";
     }
 }
Ejemplo n.º 2
0
 protected void btnMultiply_Click(object sender, EventArgs e)
 {
     try
     {
         CalculatorClass calc = new CalculatorClass();
         calc.Num1 = double.Parse(txbNum1.Text);
         calc.Num2 = double.Parse(txbNum2.Text);
         lblAnswer.Text = calc.Product.ToString();
     }
     catch (FormatException fex)
     {
         lblAnswer.Text = "Please enter numbers only!";
     }
 }
Ejemplo n.º 3
0
 protected void btnDivide_Click(object sender, EventArgs e)
 {
     try
     {
         CalculatorClass calc = new CalculatorClass();
         calc.Num1 = double.Parse(txbNum1.Text);
         calc.Num2 = double.Parse(txbNum2.Text);
         if (calc.Quotient.ToString() == "NaN")
             lblAnswer.Text = "Not a number.";
         else if (calc.Quotient.ToString() == "Infinity")
             lblAnswer.Text = "You divided a number by zero!";
         else
             lblAnswer.Text = calc.Quotient.ToString();
     }
     catch (FormatException)
     {
         lblAnswer.Text = "Please enter numbers only!";
     }
 }