C制作简易计算器

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

using System;

using ;

using ;

using ;

using ;

using MyCalculater

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

bool isDotpressed = false;

int iOperator;

float dOperand1;

float dOperand2;

float dResult;

private void textBox1_TextChanged(object sender, EventArgs e)

{

}

private void版权说明ToolStripMenuItem_Click(object sender, EventArgs e) {

Form2 newForm = new Form2();

};

isDotpressed = true;

}

}

private void btClear_Click(object sender, EventArgs e) {

= "";

}

private void btAdd_Click(object sender, EventArgs e) {

if != 0)

{

dOperand1 = ;

}

else

{

dOperand1 = 0;

}

iOperator = 1;

= "";

isDotpressed = false;

}

private void btSub_Click(object sender, EventArgs e) {

if != 0)

{

dOperand1 = ;

}

else

{

dOperand1 = 0;

}

iOperator = 2;

= "";

isDotpressed = false;

}

private void btMul_Click(object sender, EventArgs e) {

if != 0)

dOperand1 = ;

}

else

{

dOperand1 = 0;

}

iOperator = 3;

= "";

isDotpressed = false;

}

private void btDiv_Click(object sender, EventArgs e) {

if != 0)

{

dOperand1 = ;

}

else

{

dOperand1 = 0;

}

iOperator = 4;

= "";

isDotpressed = false;

}

private void btCal_Click(object sender, EventArgs e) {

if != 0)

{

dOperand2 = ;

}

else

{

dOperand2 = 0;

}

switch(iOperator)

{

case 1:

dResult = dOperand1 + dOperand2;

break;

case 2:

dResult = dOperand1 - dOperand2;

break;

case 3:

dResult = dOperand1 * dOperand2;

break;

case 4:

if(dOperand2!=0)

{

dResult = dOperand1 / dOperand2;

}

else

{

="除数不能为零!";

}

break;

default:

break;

}

=();

dOperand1=0;

dOperand2=0;

}

private void Form1_Load(object sender, EventArgs e) {

}

}

}

相关文档
最新文档