




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(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;/開(kāi)始標(biāo)志 int sp = 0;/判斷除數(shù)為零時(shí)移除監(jiān)聽(tīng) int max = 0;/范圍標(biāo)識(shí) int eq=0; #region 功能鍵 private void on_Click(object sender, EventArgs e)/開(kāi)始 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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝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ù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 付費(fèi)搭建店鋪合同范本
- 內(nèi)墻抹灰施工合同范本
- 農(nóng)民工工資付款合同范本
- 關(guān)于規(guī)范使用合同范本
- 辦公輔助崗位合同范本
- 住宅消防維修采購(gòu)合同范本
- mind+ 星球大戰(zhàn) 教學(xué)設(shè)計(jì)
- 出售貨架合同范本
- 與勞務(wù)外包簽訂合同范本
- 勘探合同屬于合同范本
- 患者隱私保護(hù)的考試試題及答案
- 2025年中考數(shù)學(xué)一輪教材復(fù)習(xí)-第六章 圓 與圓有關(guān)的概念及性質(zhì)
- 運(yùn)維服務(wù)體系建立實(shí)施方案(5篇)
- 路面基層(級(jí)配碎石)施工方案
- 2025年村兩委工作計(jì)劃
- 2025年日歷(日程安排-可直接打印)
- 事業(yè)單位考試職業(yè)能力傾向測(cè)驗(yàn)(社會(huì)科學(xué)專技類B類)試題及答案指導(dǎo)(2025年)
- 中小學(xué)反詐宣傳課件
- 口腔執(zhí)業(yè)醫(yī)師定期考核試題(資料)帶答案
- 2024年三八婦女節(jié)婦女權(quán)益保障法律知識(shí)競(jìng)賽題庫(kù)及答案(共260題)
- 北京工業(yè)大學(xué)《機(jī)器學(xué)習(xí)基礎(chǔ)》2022-2023學(xué)年期末試卷
評(píng)論
0/150
提交評(píng)論