资源预览内容
第1页 / 共14页
第2页 / 共14页
第3页 / 共14页
第4页 / 共14页
第5页 / 共14页
第6页 / 共14页
第7页 / 共14页
第8页 / 共14页
第9页 / 共14页
第10页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
首先利用visual studio里面的button和textbox模块建立上图模块。然后就是编写程序:该程序最重要的是要理解清楚计算器的运算逻辑。public partial class Form1 : Form string a, b, q, ac; int c = 0, d = 0, n = 0, p = 0, m = 0; double temp1 = -1; int pos = 0; public Form1() InitializeComponent(); private void textBox1_TextChanged(object sender, EventArgs e) public void addNum(int num) textBox1.Text = textBox1.Text + num.ToString(); if (c 0) / 管理加减?乘?除y运?算? textBox1.Text = ; a = num.ToString(); b = b + a; textBox1.Text = b; private void button1_Click(object sender, EventArgs e) addNum(7); /向显?示?屏加字? n+; private void button2_Click(object sender, EventArgs e) addNum(8); private void button3_Click(object sender, EventArgs e) addNum(9); private void button5_Click(object sender, EventArgs e) addNum(4); private void button6_Click(object sender, EventArgs e) addNum(5); private void button7_Click(object sender, EventArgs e) addNum(6); private void button9_Click(object sender, EventArgs e) addNum(1); private void button10_Click(object sender, EventArgs e) addNum(2); private void button11_Click(object sender, EventArgs e) addNum(3); private void button14_Click(object sender, EventArgs e) addNum(0); private void button15_Click(object sender, EventArgs e) if (p=0) textBox1.Text = textBox1.Text + .;/加上?小?数y点? p+; m+; if (c 0) / 管理加减?乘?除y运?算? b = b + .; private void button4_Click(object sender, EventArgs e) pos = 1; temp1 = Convert .ToDouble (textBox1.Text); textBox1.Text =temp1+; d+; c+; p = 0; private void button8_Click(object sender, EventArgs e) pos = 2; temp1 = Convert.ToDouble(textBox1.Text); textBox1.Text = temp1 + -; c+; p = 0; private void button12_Click(object sender, EventArgs e) pos = 3; temp1 = Convert.ToDouble(textBox1.Text); textBox1.Text = temp1 + *; c+; p = 0; private void button16_Click(object sender, EventArgs e) pos = 4; temp1 = Convert.ToDouble(textBox1.Text); textBox1.Text = temp1 + /; c+; p = 0; private void button13_Click(object sender, EventArgs e) double temp2 = Convert.ToDouble(b); switch (pos) case 1: textBox1.Text = (temp1 + temp2).ToString(); break; case 2: textBox1.Text = (temp1 - temp2).ToString(); break; case 3: textBox1.Text = (temp1 * temp2).ToString(); break; case 4: textBox1.Text = (temp1 / temp2).ToString(); break; private void button17_Click(object sender, EventArgs e) textBox1.Text = ;/清?空?显?示?器 temp1 = 0; pos = 0; b = ; a = ; n = 0; c = 0; p = 0; 严格执行现金管理制度和现金使用范围,遵守银行结算制度,现金银行存款按时间顺序逐笔登记,每日结出余额现金当日核对,银行存款月终必须与银行核对,做到日清月结。
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号