主题:编写一个C#计算器程序,键盘输入两个数以及+、-、*、/中的任一运算符,计算这两个数的运算结果?
//乘法
private void button14_Click(object sender, EventArgs e)
{
btn1 = Convert.ToDouble(textBox1.Text);
S1 = 4;
textBox1.Text = "";
}
private void button17_Click(object sender, EventArgs e)
{
switch (S1)
{
case 1:
btn2 = btn1 + Convert.ToDouble(textBox1.Text);
textBox1.Text = btn1.ToString();
break;
case 2:
btn2 = btn1 - Convert.ToDouble(textBox1.Text);
textBox1.Text = btn2.ToString();
break;
case 3:
btn2 = btn1 / Convert.ToDouble(textBox1.Text);
textBox1.Text = btn2.ToString();
break;
case 4:
btn2 = btn1 * Convert.ToDouble(textBox1.Text);
textBox1.Text = btn2.ToString();
break;
}
}
private void button14_Click(object sender, EventArgs e)
{
btn1 = Convert.ToDouble(textBox1.Text);
S1 = 4;
textBox1.Text = "";
}
private void button17_Click(object sender, EventArgs e)
{
switch (S1)
{
case 1:
btn2 = btn1 + Convert.ToDouble(textBox1.Text);
textBox1.Text = btn1.ToString();
break;
case 2:
btn2 = btn1 - Convert.ToDouble(textBox1.Text);
textBox1.Text = btn2.ToString();
break;
case 3:
btn2 = btn1 / Convert.ToDouble(textBox1.Text);
textBox1.Text = btn2.ToString();
break;
case 4:
btn2 = btn1 * Convert.ToDouble(textBox1.Text);
textBox1.Text = btn2.ToString();
break;
}
}