版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace test1 public partial class Form1 : Form public string a; public string a1; public string sign; public string sign_qe;/定义一个缺额标记 publi
2、c string sign_sum;/定义加号标记 public string sign_sub;/定义减号标记 public string sign_mul;/定义乘号标记 public string sign_div;/定义除号标记 public string sign_dian;/定义小数点标记 public string sign_bfhao;/定义一个百分号标记 public string sign_equ;/等于号标记 public string cpy;/导航菜单用于复制的内容数据 public double b = 10241024.10241023;/定义一个操作数b pub
3、lic double c = 10241024.10241023;/定义一个操作数据c public double g = 0;/定义一个操作数g public string d;/等于号记忆运算符 public double x;/求倒数 public double f;/百分号暂存记忆运算符 public double e;/缺额运算符 public double m;/内存记忆运算符 public double M;/内存记忆运算符 public double s = 0;/根号运算符 public bool wuxiao = true;/定义一个除数不能为零的数 public bool
4、 teshu = true;/定义一个特殊标记 public string zhantie=null; public bool clock=true;/锁定按键运算符 public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) this.Text = 计算器; private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)/复制 Clipboard.SetText(txt_show.Text, TextDa
5、taFormat.Text); private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)/粘贴 a1 = Clipboard.GetText(); zhantie = null; for (int i = 0; i a1.Length; i+) if (int)a1i 57) zhantie = zhantie; break; if (zhantie != zhantie) txt_show.Text = Clipboard.GetText(); this.a = this.txt_show.Text; private
6、 void 标准型ToolStripMenuItem_Click(object sender, EventArgs e) private void 帮助ToolStripMenuItem_Click(object sender, EventArgs e)/帮助 Help.ShowHelp(this, C:WINDOWShELPcalc.chm); private void btn_0_Click(object sender, EventArgs e)/数字0键 if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空
7、显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_0.Text;/给a赋上0 this.txt_show.Text += this.btn_0.Text;/将0显示在显示器上 this.teshu = true; else this.txt_show.Text = 不能同时输入多个0!; /防止输入多个0 else this.txt_show.Text = null;/清空显示器上显示的0 this.txt_show.Text = this.btn_0.Text; this.a += this.btn_0.Text;/给a
8、赋值为输入的0 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void btn_1_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_1.Text;/给a赋上1 this.txt_show.Text += this.btn_1.Text;/将1显示在显示
9、器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的1 this.txt_show.Text = this.btn_1.Text; this.a += this.btn_1.Text;/给a 赋值为输入的1 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void btn_2_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Te
10、xt = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_2.Text;/给a赋上2 this.txt_show.Text += this.btn_2.Text;/将2显示在显示器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的2 this.txt_show.Text = this.btn_2.Text; this.a += this.btn_2.Text;/给a 赋值为输入的2 if (sign != null) this.sig
11、n_qe = null;/对缺额标记的内容进行清空 private void btn_3_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_3.Text;/给a赋上3 this.txt_show.Text += this.btn_3.Text;/将3显示在显示器上 this.teshu = true; else this.tx
12、t_show.Text = null;/清空显示器上显示的3 this.txt_show.Text = this.btn_3.Text; this.a += this.btn_3.Text;/给a 赋值为输入的3 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void btn_4_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断
13、在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_4.Text;/给a赋上4 this.txt_show.Text += this.btn_4.Text;/将4显示在显示器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的4 this.txt_show.Text = this.btn_4.Text; this.a += this.btn_4.Text;/给a 赋值为输入的4 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private
14、void btn_5_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_5.Text;/给a赋上5 this.txt_show.Text += this.btn_5.Text;/将5显示在显示器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的5 thi
15、s.txt_show.Text = this.btn_5.Text; this.a += this.btn_5.Text;/给a 赋值为输入的5 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void btn_6_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this
16、.btn_6.Text;/给a赋上6 this.txt_show.Text += this.btn_6.Text;/将1显示在显示器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的6 this.txt_show.Text = this.btn_6.Text; this.a += this.btn_6.Text;/给a 赋值为输入的6 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void btn_7_Click(object sender, Ev
17、entArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_7.Text;/给a赋上7 this.txt_show.Text += this.btn_7.Text;/将7显示在显示器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的7 this.txt_show.Text = this.btn_7.Text;
18、 this.a += this.btn_7.Text;/给a 赋值为输入的7 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void btn_8_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_8.Text;/给a赋上8 this.txt_show.T
19、ext += this.btn_8.Text;/将8显示在显示器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的8 this.txt_show.Text = this.btn_8.Text; this.a += this.btn_8.Text;/给a 赋值为输入的8 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void btn_9_Click(object sender, EventArgs e) if (wuxiao = true) if (
20、teshu = false) this.txt_show.Text = null;/清空显示器的内容 if (a != 0)/判断在一开始运算按下的第一个按钮是不是为零 this.a += this.btn_9.Text;/给a赋上8 this.txt_show.Text += this.btn_9.Text;/将8显示在显示器上 this.teshu = true; else this.txt_show.Text = null;/清空显示器上显示的8 this.txt_show.Text = this.btn_9.Text; this.a += this.btn_9.Text;/给a 赋值为
21、输入的8 if (sign != null) this.sign_qe = null;/对缺额标记的内容进行清空 private void backspace_Click(object sender, EventArgs e)/后退键 if (wuxiao = true) if (a = null) /this.txt_show.Text = 请输入数据!; else if (a.Length != 0) this.txt_show.Text = a.Remove(a.Length - 1, 1).ToString();/显示区域上的数据 a = a.Remove(a.Length - 1,
22、1);/计算器内部数据向后退一 else this.txt_show.Text = 0.; this.teshu = false;/做特有的加号标记 private void ce_Click(object sender, EventArgs e)/一次运算完成后点击该按钮便会清空数据,再次输入就开始新的运算 this.txt_show.Text = 0.; this.a = null;/记录数据清空 this.sign = null; this.sign_sum = null; this.sign_sub = null; this.sign_mul = null; this.sign_div
23、 = null; this.sign_equ = null; this.sign_bfhao = null; this.sign_dian = null; this.sign_qe = null; this.b = 10241024.10241023; this.c = 10241024.10241023; this.d = null; this.f = 0; this.x = 0; this.s = 0; this.clock = true; this.wuxiao = true; /对各个数据进行初始化 private void div_Click(object sender, Event
24、Args e)/除号 if (wuxiao = true) if (this.a = .) else this.sign = this.btn_div.Text;/做运算符的通用标记 if (c=10241024.10241023)/判断是否与其他运算有关联 this.sign_div = this.btn_div.Text;/对除法做除号标记 b = 0; c = 0; this.sign_qe = this.btn_div.Text;/做缺额标记 this.c += Convert.ToDouble(a);/a的值赋给c this.e = this.c; this.f = this.e;
25、a = null;/将a的值置为0 sign_dian = null; else if (sign_equ = = & a != null)/按下等于号 开始新的运算 this.sign_equ = null; this.sign_div = null; this.c = 0; this.e = 0; this.c += Convert.ToDouble(a);/将a的值赋给c this.a = null; this.sign_div = this.btn_div.Text;/标记 return; else if (sign_div = / & sign_qe != / & sign_equ
26、= =)/判断是否联除 this.b += Convert.ToDouble(a); if (b = 0)/判断除数是否为0 if (b = 0 & c = 0) this.txt_show.Text = 0; this.clock = false; return; else c = 0; this.txt_show.Text = null; this.txt_show.Text = 除数不能为0!; this.wuxiao = false; return; this.c /= this.b; b = 0; a = null; sign_dian = null; this.txt_show.T
27、ext = Convert.ToString(c);/显示器上显示结果 return; else this.b += Convert.ToDouble(a);/将a的值传递给b this.sign_div = this.btn_div.Text; if (sign_sum = +) this.c += this.b; sign_sum = null; else if (sign_sub = -) this.c -= this.b; sign_sub = null; else if (sign_mul = *) this.c *= this.b; sign_mul = null; a = null; b = 0; sign_dian = null; this.txt_show.Text = Convert.ToString(c); return; private void mul_Click(object sender, EventArgs e)/乘号 if (wuxiao = true) if (this.a = .) else
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年细胞工厂灌流培养工艺开发指南
- 2026年五轴刀具磨床线性马达与光栅尺集成设计
- 山东省莒北五校2025-2026学年初三适应性月考(一)生物试题含解析
- 2026年广东省佛山市超盈实验中学初三第四次月考生物试题月考试题含解析
- 2026届湖南邵阳市区中考适应性月考卷(三)化学试题含解析
- 2026届安徽省太和县民族中学初三生物试题9月17日第3周测试题含解析
- 2026年GUI智能体技术原理手机看到屏幕内容模拟点击操作
- 山东省济南槐荫区五校联考2026年初三下学期押题卷第四套(全国统一考试考前训练6月2日)化学试题含解析
- 广东省中学山市黄圃镇马新初级中学2026年初三年级第二次教学质量检查考试生物试题含解析
- 2026届安徽省亳州市涡阳县石弓中心校初三“零诊”考试生物试题含解析
- 泌尿外科品管圈
- 《准备单元雪地上的“足迹”》教学课件
- (正式版)JBT 14682-2024 多关节机器人用伺服电动机技术规范
- 心理健康家庭教育指导活动
- 2023年6月新高考天津卷英语试题真题及答案解析(精校打印版)
- 红楼梦林黛玉进贾府原文朗读
- 生命的起源与早期演化课件
- 上海市市西中2024学年高三下学期精英联赛英语试题含解析
- 2023年全国高校体育单招考试英语试卷试题及答案详解1
- 满族文化-大学课件
- GB/T 38119-2019邵氏硬度计的检验
评论
0/150
提交评论