




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
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;/定義小數(shù)點標記 public string sign_bfhao;/定義一個百分號標記 public string sign_equ;/等于號標記 public string cpy;/導(dǎo)航菜單用于復(fù)制的內(nèi)容數(shù)據(jù) public double b = 10241024.10241023;/定義一個操作數(shù)b pub
3、lic double c = 10241024.10241023;/定義一個操作數(shù)據(jù)c public double g = 0;/定義一個操作數(shù)g public string d;/等于號記憶運算符 public double x;/求倒數(shù) public double f;/百分號暫存記憶運算符 public double e;/缺額運算符 public double m;/內(nèi)存記憶運算符 public double M;/內(nèi)存記憶運算符 public double s = 0;/根號運算符 public bool wuxiao = true;/定義一個除數(shù)不能為零的數(shù) 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 復(fù)制ToolStripMenuItem_Click(object sender, EventArgs e)/復(fù)制 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)/數(shù)字0鍵 if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空
7、顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_1_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_2_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Te
10、xt = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_3_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_4_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private
14、void btn_5_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_6_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_7_Click(object sender, Ev
17、entArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_8_Click(object sender, EventArgs e) if (wuxiao = true) if (teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void btn_9_Click(object sender, EventArgs e) if (wuxiao = true) if (
20、teshu = false) this.txt_show.Text = null;/清空顯示器的內(nèi)容 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;/對缺額標記的內(nèi)容進行清空 private void backspace_Click(object sender, EventArgs e)/后退鍵 if (wuxiao = true) if (a = null) /this.txt_show.Text = 請輸入數(shù)據(jù)!; else if (a.Length != 0) this.txt_show.Text = a.Remove(a.Length - 1, 1).ToString();/顯示區(qū)域上的數(shù)據(jù) a = a.Remove(a.Length - 1,
22、1);/計算器內(nèi)部數(shù)據(jù)向后退一 else this.txt_show.Text = 0.; this.teshu = false;/做特有的加號標記 private void ce_Click(object sender, EventArgs e)/一次運算完成后點擊該按鈕便會清空數(shù)據(jù),再次輸入就開始新的運算 this.txt_show.Text = 0.; this.a = null;/記錄數(shù)據(jù)清空 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; /對各個數(shù)據(jù)進行初始化 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)/判斷是否與其他運算有關(guān)聯(lián) 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、= =)/判斷是否聯(lián)除 this.b += Convert.ToDouble(a); if (b = 0)/判斷除數(shù)是否為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 = 除數(shù)不能為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);/顯示器上顯示結(jié)果 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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 農(nóng)村板車出售合同范例
- 公司注銷業(yè)務(wù)合同范本
- 中醫(yī)診所招聘合同范本
- 單位出售土地合同范本
- 公司車定維修合同范本
- 共享出租場地合同范本
- 勞務(wù)聯(lián)營合同范例
- 加油站出租合同范本
- 企業(yè)賦能合同范本
- 二手房房東出租合同范例
- (2024年)中國傳統(tǒng)文化介紹課件
- 糖尿病患者飲食指導(dǎo)課件
- 人工智能數(shù)據(jù)標注百億產(chǎn)業(yè)詳細介紹
- 2023年高考真題-地理(天津卷) 含答案
- 2024年10月自考02160流體力學試題及答案含評分參考
- 2025年公務(wù)員考試《行測》模擬題及答案(詳細解析)
- 2024年黑龍江省牡丹江市中考歷史試卷
- 滬科版八年級物理知識點總結(jié)
- 孫權(quán)勸學(原卷版)-2024年中考語文之文言文對比閱讀
- 高速公路日常清掃與養(yǎng)護方案
- 風電epc合同模板
評論
0/150
提交評論