Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Calculator function

$
0
0

Hey there,

I am trying to create do addition subtraction multiplation and division with only one "calculate" button. The following is the code i came up with however its not working exactly the way i want it to.

protected void Button1_Click(object sender, EventArgs e)
{
int number1 = int.Parse(TxtBox.Text);
int number2 = int.Parse(TxtBox2.Text);

int sum = number1 + number2;
TxtBox3.Text = sum.ToString();
int minus = number1 - number2;
TxtBox3.Text = minus.ToString();
int multiply = number1 * number2;
TxtBox3.Text = multiply.ToString();
int divide = number1 / number2;
TxtBox3.Text = divide.ToString();

}

Also i would like to convert the answer from base10 to base20. Any hint on how can that be done ?

Cheers


Viewing all articles
Browse latest Browse all 23244

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>