ImageVerifierCode 换一换
格式:DOCX , 页数:23 ,大小:42.34KB ,
资源ID:6952426      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6952426.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(windows7系统自带计算器.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

windows7系统自带计算器.docx

1、windows7系统自带计算器using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 计算器2 public partial class Form1 : Form private double fNum = 0;/输入的前一个数数字表示 private double lNum = 0

2、;/输入的后一个数 private string sfNum = null;/输入的前一个数字符表示 private string slNum = null;/输入的后一个数 private char Sym ;/确定运算的符号+- private bool ord = false;/确定是否按了+-*/若真就表示按了 private int CountNum = 0;/确定输入数的个数 private int e1 = 0;/0表示没按等号,1表示按了等号 private bool cequ = false;/表示是否是连等于 private string stemp;/用于存缓存的数值/字

3、符串 private double temp; private string strmain;/用于存储输入的所有数,在第一行显示 private string fuzhan;/用于存储选项卡中复制粘贴的数 public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) textBox1.Text = 0; private void yunsuan()/四则运算 fNum = double.Parse(sfNum); lNum = double.Parse(slNum); swi

4、tch (Sym) case a: fNum += lNum; break; case r: fNum -= lNum; break; case m: fNum *= lNum; break; case d: fNum /= lNum; break; sfNum = fNum.ToString(); slNum = null; private void lianyunsuan()/连续运算 if (CountNum 0) yunsuan(); textBox1.Text = sfNum; else CountNum+; private void btn62_Click(object sende

5、r, EventArgs e)/小数点 ord = false; cequ = true; if (e1 = 1)/前面按了等号第一个数归0 strmain = null; sfNum = null; e1 = 0; strmain += .; if (CountNum = 0) if (sfNum = null) sfNum += 0.; else sfNum += .; textBox1.Text = sfNum; else if (slNum = null) slNum += 0.; else slNum += .; textBox1.Text = slNum; private void

6、 btn61_Click(object sender, EventArgs e)/数字0 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 0; if (CountNum = 0 & sfNum != 0) sfNum += 0; textBox1.Text = sfNum; else if(slNum != 0) slNum += 0; textBox1.Text = slNum; private void btn51_Click(object sender, Even

7、tArgs e)/数字1 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 1; if (CountNum = 0) if (sfNum != 0) sfNum += 1; else sfNum = 1; textBox1.Text = sfNum; else if (slNum != 0) slNum += 1; else slNum = 1; textBox1.Text = slNum; private void btn52_Click(object sender,

8、EventArgs e)/数字2 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 2; if (CountNum = 0) if (sfNum != 0) sfNum += 2; else sfNum = 2; textBox1.Text = sfNum; else if (slNum != 0) slNum += 2; else slNum = 2; textBox1.Text = slNum; private void btn53_Click(object send

9、er, EventArgs e)/数字3 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 3; if (CountNum = 0) if (sfNum != 0) sfNum += 3; else sfNum = 3; textBox1.Text = sfNum; else if (slNum != 0) slNum += 3; else slNum = 3; textBox1.Text = slNum; private void btn41_Click(object

10、sender, EventArgs e)/数字4 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 4; if (CountNum = 0) if (sfNum != 0) sfNum += 4; else sfNum = 4; textBox1.Text = sfNum; else if (slNum != 0) slNum += 4; else slNum = 4; textBox1.Text = slNum; private void btn42_Click(obj

11、ect sender, EventArgs e)/数字5 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 5; if (CountNum = 0) if (sfNum != 0) sfNum += 5; else sfNum = 5; textBox1.Text = sfNum; else if (slNum != 0) slNum += 5; else slNum = 5; textBox1.Text = slNum; private void btn43_Click

12、(object sender, EventArgs e)/数字6 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 6; if (CountNum = 0) if (sfNum != 0) sfNum += 6; else sfNum = 6; textBox1.Text = sfNum; else if (slNum != 0) slNum += 6; else slNum = 6; textBox1.Text = slNum; private void btn31_C

13、lick(object sender, EventArgs e)/数字7 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 7; if (CountNum = 0) if (sfNum != 0) sfNum += 7; else sfNum = 7; textBox1.Text = sfNum; else if (slNum != 0) slNum += 7; else slNum = 7; textBox1.Text = slNum; private void btn

14、32_Click(object sender, EventArgs e)/数字8 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 8; if (CountNum = 0) if (sfNum != 0) sfNum += 8; else sfNum = 8; textBox1.Text = sfNum; else if (slNum != 0) slNum += 8; else slNum = 8; textBox1.Text = slNum; private void

15、 btn33_Click(object sender, EventArgs e)/数字9 ord = false; cequ = true; if (e1 = 1) strmain = null; sfNum = null; e1 = 0; strmain += 9; if (CountNum = 0) if (sfNum != 0) sfNum += 9; else sfNum = 9; textBox1.Text = sfNum; else if (slNum != 0) slNum += 9; else slNum = 9; textBox1.Text = slNum; private

16、void btn63_Click(object sender, EventArgs e)/加法 if (ord) strmain = strmain.Substring(0, strmain.Length - 1); strmain += +; textBox2.Text = strmain; else strmain += +; textBox2.Text = strmain; ord = true; lianyunsuan(); cequ = true; e1 = 0; textBox1.Text = null; Sym = a; private void btn54_Click(obje

17、ct sender, EventArgs e)/减法 if (ord) strmain = strmain.Substring(0, strmain.Length - 1); strmain += -; textBox2.Text = strmain; else strmain += -; textBox2.Text = strmain; ord = true; lianyunsuan(); cequ = true; e1 = 0; textBox1.Text = null; Sym = r; private void btn44_Click(object sender, EventArgs

18、e)/乘法 if (ord) strmain = strmain.Substring(0, strmain.Length - 1); strmain += *; textBox2.Text = strmain; else strmain += *; textBox2.Text = strmain; ord = true; lianyunsuan(); cequ = true; e1 = 0; textBox1.Text = null; Sym = m; private void btn34_Click(object sender, EventArgs e)/除法 if (ord) strmai

19、n = strmain.Substring(0, strmain.Length - 1); strmain += /; textBox2.Text = strmain; else strmain += /; textBox2.Text = strmain; ord = true; lianyunsuan(); cequ = true; e1 = 0; textBox1.Text = null; Sym = d; private void btn64_Click(object sender, EventArgs e)/等于号 ord = false; textBox2.Text = null;

20、e1 = 1; if (cequ) if (Sym = d & slNum = 0) textBox1.Text = 除数不能为0; else yunsuan(); CountNum = 0; textBox1.Text = sfNum; cequ = false; else switch (Sym) case a: fNum += lNum; break; case r: fNum -= lNum; break; case m: fNum *= lNum; break; case d: fNum /= lNum; break; sfNum = fNum.ToString(); textBox

21、1.Text = sfNum; strmain = sfNum; private void btn45_Click(object sender, EventArgs e)/求倒数 if (CountNum = 0) fNum = double.Parse(sfNum); fNum = 1 / fNum; sfNum = fNum.ToString(); textBox1.Text = sfNum; else lNum = double.Parse(slNum); lNum = 1 / lNum; slNum = lNum.ToString(); textBox1.Text = slNum; p

22、rivate void btn35_Click(object sender, EventArgs e)/输入百分数并输出结果 if (CountNum = 0) fNum = double.Parse(sfNum); fNum /= 100; sfNum = fNum.ToString(); textBox1.Text = sfNum; else lNum = double.Parse(slNum); lNum /= 100; slNum = lNum.ToString(); textBox1.Text = slNum; private void btn25_Click(object send

23、er, EventArgs e)/根号 if (CountNum = 0) textBox2.Text = sqrt( + sfNum + ); fNum = double.Parse(sfNum); fNum = System.Math.Sqrt(fNum); sfNum = fNum.ToString(); textBox1.Text = sfNum; else textBox2.Text = sqrt( + slNum + ); lNum = double.Parse(slNum); lNum = System.Math.Sqrt(lNum); slNum = lNum.ToString

24、(); textBox1.Text = slNum; private void btn23_Click(object sender, EventArgs e)/清除 CountNum = 0; e1 = 0; strmain = null; sfNum = null; slNum = null; textBox1.Text = null; textBox2.Text = null; private void btn22_Click(object sender, EventArgs e)/ 归零 if (CountNum = 0) sfNum = null; textBox1.Text = sf

25、Num; else slNum = null; textBox1.Text = slNum; private void btn21_Click(object sender, EventArgs e)/删除当前数的一位一位 if (CountNum = 0) if (sfNum.Length != null) sfNum = sfNum.Substring(0, sfNum.Length - 1); textBox1.Text = sfNum; else if (slNum.Length != null) slNum = slNum.Substring(0, slNum.Length - 1);

26、 textBox1.Text = slNum; private void btn24_Click(object sender, EventArgs e)/改变数的正负号 if (CountNum = 0) fNum = double.Parse(sfNum); fNum = 0 - fNum; sfNum = fNum.ToString(); textBox1.Text = sfNum; else lNum = double.Parse(slNum); lNum = 0 - lNum; slNum = lNum.ToString(); textBox1.Text = slNum; private void btn13_Click(object sender, EventArgs e)/将当前数存入记忆缓存 label1.Text = M; if (CountNum = 0) stemp = sfNum; else stemp = slNum; private void btn12_Click(object sender, EventArgs e)/使用记忆缓存 if (CountNum = 0) sfNum = stemp; textBox1.Text = sfNum; else slNum = stemp; textBox1.Text =

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1