版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Calculator public partial class Counter : Form public Counter() InitializeComponent(); double num1, num2; double result=0; int op; i
2、nt flag=0;/開始標(biāo)志 int sp = 0;/判斷除數(shù)為零時(shí)移除監(jiān)聽 int max = 0;/范圍標(biāo)識(shí) int eq=0; #region 功能鍵 private void on_Click(object sender, EventArgs e)/開始 flag = 1; sp = 0; max = 0; this.numInput.Text = "0" this.txtInput.Text = "" private void off_Click(object sender, EventArgs e)/關(guān)閉 flag = 0; sp = 0;
3、 max = 0; this.numInput.Text = "" this.txtInput.Text = "" private void button9_Click(object sender, EventArgs e)/刪除 max = 0; if (flag = 1&&sp=0) string numstring = this.numInput.Text; if (numstring.Length > 0) string temp = numstring.Substring(0, numstring.Length - 1);
4、 this.numInput.Text = temp.ToString(); else this.numInput.Text = "0" private void clear_Click(object sender, EventArgs e)/c清零 max = 0; if (flag = 1) sp = 0; this.numInput.Text = "0" this.txtInput.Text = "" private void delete_Click(object sender, EventArgs e)/清零 max = 0
5、; if (flag = 1) sp = 0; this.numInput.Text = "0" #endregion #region 運(yùn)算符 private void equal_Click(object sender, EventArgs e)/等號(hào) eq = 1; if (flag = 1 && sp = 0) max = 0; num2 = Convert.ToDouble(this.numInput.Text); this.txtInput.Text += num2.ToString(); this.txtInput.Text += "=
6、" txtInput.Text = null; switch (op) case 1: result = num1 + num2; break; case 2: result = num1 - num2; break; case 3: result = num1 * num2; break; case 4: result = num1 / num2; break; case 5: result = Math.Pow(num1, num2); break; case 6: result = Mod(num1, num2); break; default: return; if (op
7、= 4&&num2 = 0) this.numInput.Text = "除數(shù)不能為0" sp = 1; else /this.txtInput.Text += result.ToString(); this.numInput.Text = result.ToString(); private void sub_Click(object sender, EventArgs e)/減法 max = 0; if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); th
8、is.txtInput.Text += num1.ToString(); numInput.Text = "" this.txtInput.Text += "-" op = 2; private void mul_Click(object sender, EventArgs e)/乘法 max = 0; if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); this.txtInput.Text += num1.ToString(); this.numInp
9、ut.Text = "" this.txtInput.Text += "*" op = 3; private void divide_Click(object sender, EventArgs e)/除法 max = 0; if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); this.txtInput.Text += num1.ToString(); this.numInput.Text = "" this.txtInput.Tex
10、t += "/" op = 4; private void plus_Click(object sender, EventArgs e)/加法 max = 0; if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); this.txtInput.Text += num1.ToString(); numInput.Text = "" this.txtInput.Text += "+" op = 1; public double Mod(do
11、uble x, double y)/取模運(yùn)算 max = 0; int temp = Convert.ToInt32(x / y); return (x - y * temp); private void power_Click(object sender, EventArgs e)/冪運(yùn)算 max = 0; if (flag = 1 && sp = 0) num1 = Convert.ToDouble(numInput.Text); this.txtInput.Text += num1.ToString(); this.numInput.Text = ""
12、 this.txtInput.Text += "" op = 5; private void recip_Click(object sender, EventArgs e)/倒數(shù) max = 0; if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); double temp = 0; temp = 1 / num1; this.txtInput.Text = "1/" + num1.ToString() + "=" this.numIn
13、put.Text = temp.ToString(); private void percent_Click(object sender, EventArgs e) max = 0; if (flag = 1 && sp = 0) /double temp = Convert.ToDouble(this.numInput.Text); /this.txtInput.Text += temp.ToString(); /temp = temp / 100; /this.numInput.Text = temp.ToString(); /this.txtInput.Text += &
14、quot;%=" num1 = Convert.ToDouble(this.numInput.Text); this.txtInput.Text += num1.ToString(); this.numInput.Text = "" this.txtInput.Text += "%" op = 6; #endregion #region 數(shù)字 private void one_Click(object sender, EventArgs e)/1 if (flag = 1 && sp = 0 && max = 0
15、) if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "1" eq = 0; else this.numInput.Text += "1" private void two_Click(object sender, EventArgs e)/2 if (flag = 1 && sp = 0 && max = 0) if (this.numInput.Text =
16、 "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "2" eq = 0; else this.numInput.Text += "2" /this.txtInput.Text += "2" private void three_Click(object sender, EventArgs e)/3 if (flag = 1 && sp = 0 && max = 0) if (this.nu
17、mInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "3" eq = 0; else this.numInput.Text += "3" /this.txtInput.Text += "3" private void four_Click(object sender, EventArgs e)/4 if (flag = 1 && sp = 0 && max = 0)
18、 if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "4" eq = 0; else this.numInput.Text += "4" / this.txtInput.Text += "4" private void five_Click(object sender, EventArgs e)/5 if (flag = 1 && sp = 0 &&
19、amp; max = 0) if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "5" eq = 0; else this.numInput.Text += "5" /this.txtInput.Text += "5" private void six_Click(object sender, EventArgs e)/6 if (flag = 1 && sp
20、 = 0 && max = 0) if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "6" eq = 0; else this.numInput.Text += "6" /this.txtInput.Text += "6" private void seven_Click(object sender, EventArgs e)/7 if (flag = 1
21、&& sp = 0 && max = 0) if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "7" eq = 0; else this.numInput.Text += "7" /this.txtInput.Text += "7" private void eight_Click(object sender, EventArgs e)/8
22、if (flag = 1 && sp = 0 && max = 0) if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "8" eq = 0; else this.numInput.Text += "8" /this.txtInput.Text += "8" private void night_Click(object sender, Ev
23、entArgs e)/9 if (flag = 1 && sp = 0 && max = 0) if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "9" eq = 0; else this.numInput.Text += "9" /this.txtInput.Text += "9" private void zero_Click(objec
24、t sender, EventArgs e)/0 if (flag = 1 && sp = 0 && max = 0) if (this.numInput.Text = "0") this.numInput.Text = "" if (eq = 1) this.numInput.Text = "0" eq = 0; else this.numInput.Text += "0" /this.txtInput.Text += "0" private void dian
25、_Click(object sender, EventArgs e)/小數(shù)點(diǎn) if (flag = 1 && sp = 0 && max = 0) if (eq = 1) this.numInput.Text = "." eq = 0; else this.numInput.Text += "." /this.txtInput.Text += "." #endregion #region 三角函數(shù) private void sin_Click(object sender, EventArgs e)/si
26、n if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); double temp = Math.PI * (num1 / 180); this.txtInput.Text += "sin(" + num1 + ")=" num1 = Math.Sin(temp); this.numInput.Text = num1.ToString(); /this.txtInput.Text += num1.ToString(); private void cos_Cl
27、ick(object sender, EventArgs e)/cos if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); double temp = Math.PI * (num1 / 180); this.txtInput.Text += "cos(" + num1 + ")=" num1 = Math.Cos(temp); this.numInput.Text = num1.ToString(); private void tan_Click(ob
28、ject sender, EventArgs e)/tan if (flag = 1 && sp = 0) num1 = Convert.ToDouble(this.numInput.Text); double temp = Math.PI * (num1 / 180); this.txtInput.Text += "tan(" + num1 + ")=" num1 = Math.Tan(temp); this.numInput.Text = num1.ToString(); #endregion #region 幫助 private v
29、oid 關(guān)于產(chǎn)品ToolStripMenuItem_Click(object sender, EventArgs e) MenuAbout about = new MenuAbout(); about.Show(); private void change_Click(object sender, EventArgs e) max = 0; if (flag = 1&&sp = 0) num1 = Convert.ToDouble(this.numInput.Text); num1 = -num1; this.numInput.Text = num1.ToString(); p
30、rivate void 使用手冊(cè)ToolStripMenuItem_Click(object sender, EventArgs e) MenuUse use = new MenuUse(); use.Show(); #endregion #region 皮膚 private void 皮膚1ToolStripMenuItem_Click(object sender, EventArgs e) skinEngine1.SkinFile = Application.StartupPath + "Calmness.ssk" private void 皮膚2ToolStripMenuItem_Click(object sender, EventArgs e) skinEngine1.SkinFile = Application.StartupPath + "DeepCyan.ssk" private void 皮膚3ToolStripMenuItem_Click(object sender, EventArgs e) skinEngine1.SkinFile =
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2023三年級(jí)語(yǔ)文下冊(cè) 第七單元 語(yǔ)文園地配套教案 新人教版
- 自招保安合同(2篇)
- 唐詩(shī)《墨梅》課件
- 經(jīng)營(yíng)杠桿 課件
- 西京學(xué)院《數(shù)字邏輯與數(shù)字電路》2022-2023學(xué)年期末試卷
- 幼兒園小班音樂 《大魚和小魚》課件
- 西京學(xué)院《建設(shè)法規(guī)》2022-2023學(xué)年第一學(xué)期期末試卷
- HF均相離子交換膜
- 西京學(xué)院《廣告攝影與攝像》2023-2024學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《房地產(chǎn)開發(fā)經(jīng)營(yíng)與管理》2022-2023學(xué)年第一學(xué)期期末試卷
- 集裝箱購(gòu)銷協(xié)議合同范本示例
- 求職面試技巧培訓(xùn)
- 室內(nèi)裝修施工安全方案
- 工程詢價(jià)合同模板
- 事業(yè)單位招聘《綜合基礎(chǔ)知識(shí)》考試試題及答案
- 無錫風(fēng)機(jī)吊裝施工方案
- 《突發(fā)事件應(yīng)急預(yù)案管理辦法》知識(shí)培訓(xùn)
- 江蘇省南京市建鄴區(qū)2024-2025學(xué)年九年級(jí)上學(xué)期期中考試物理試題(無答案)
- 中小學(xué)師德師風(fēng)建設(shè)各項(xiàng)制度匯編
- 第九章 職業(yè)健康安全與環(huán)境管理課件
- 2024年保安員證考試題庫(kù)及答案(共260題)
評(píng)論
0/150
提交評(píng)論