




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、using System;using System Collections Generic;using SystemComponentModel;using System .Data;using SystemDrawing;using System .Text;using System Windows Forms;namespace Calculatorpublic partial class Counter : Formpublic Counter0InitializeComponent();doub1e num1, num2;double result=0;int op;int flag=
2、0;/開始標志int sp = 0;/判斷除數為零時移除監聽int max = 0;/范圍標識int eq=0;Sregion 功能鍵private void on_Click(object sender, EventArgs e) 丿卜始flag = 1;sp = 0;max = 0;thisnumlnput .Text = 0;thistxtlnput .Text =private void off_Click(object sender, EventArgs e) 關閉flag = 0;sp = 0;max = 0;thisnumlnput .Text =thistxtlnput .Te
3、xt =private void button9_Click(object sender, EventArgs e).,刪除if (flag = l&sp=O)string numstring = thisnumlnput.Text;if (numstring Length 0)string temp = numstringSubstring(0, numstring .Length 一 1): this numinput Text = temp ToString 0;elsethisnumlnput .Text = 0;private void clearedick(object sende
4、r, EventArgs e)/ c;nmax = 0;if (flag = 1)sp = 0;thisnumlnput .Text = 0;thistxtInput .Text =private void delete_Click(object sender, EventArgs e) . Jrimax = 0;if (flag = 1)sp = o;thisnuminput .Text = 0;SendregionSregion 運算符private void equal_Click(object sender, EventArgs e) T等:;eq = 1;if (flag = 1 &
5、 sp = 0)max = 0;num2 = Convert ToDouble(this numlnput Text); this txt Input Text 二 num2 ToStringO ;thistxtInput .Text +二二txtInput .Text = null:switch (op)case 1: result = numl 十 num2: break;case 2: result = numl - num2; break;case 3: result = numl * num2: break;case 4:result = numl / num2:break;case
6、 5:result = Math Pow(numl,num2);break;num2);case 6: result = Mod(numl,break;default: return;if (op=4&num2 = 0)this, numlnput. Text =除數不能為0;sp = 1;elsethis txt Input Te/t += result ToStringO; this .numlnput .Text = result .ToStringO;private void sub_Click(object sender, EventArgs e)/ 減法 max = 0;if (f
7、lag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text);this txt Input Text += num 1 ToStringO ; numinput .Text = ”;thistxtInput .Text +=op = 2;private void mul_Click(object sender, EventArgs e)乘法max = 0;if (flag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text);this txt Input Text += nx
8、im 1 ToStringO ;this .numlnput .Text =:thistxtInput .Text +=op = 3;private void divide_Click(object sender, EventArgs e) T除法max = 0;if (flag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text);this txt Input Text += num 1 ToStringO ;this .numlnput .Text =:thistxtInput .Text +=*;op = 4;private v
9、oid plus_Click(object sender, EventArgs e); AlHlij;max = 0;if (flag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text);this txt Input Text += num 1 ToStringO ;numlnput .Text =”;thistxtInput .Text +=十op = 1;J public double Mod (double x, double y)/取模運算max = 0;int temp = ConvertToInt32(x / y);re
10、turn (x y * temp);private void power_Click(object sender, EventArgs e) 錦運算max = 0;if (flag = 1 & sp = 0)numl = Convert ToDouble(numinput Text);this txt Input Text += nxim 1 ToStringO ;this numinput Text =:this txt Input .Text +=op = 5;Jprivate void recip_Click(object sender, EventArgs e), 倒數max = 0;
11、if (flag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text);double temp = 0;temp = 1 / numl:this txt Input .Text =1 + num 1 ToStringO +=;this nximlnput Text = temp ToStringO ;private void percent_Click(object sender, EventArgs e)max = 0;if (flag = 1 & sp = 0)double temp = ConvertToDouble(this.
12、numlnput.Text);/this txtInput Text += temp ToString0;/temp = temp / 100;/this numinput Text = temp ToStringO;/thistxtInput .Text +=numl = Convert ToDouble(this numlnput Text);this txt Input Text += num 1 ToStringO ;this .numlnput .Text =thistxtInput .Text 二 %op = 6;SendregionSregion 數字private void o
13、ne_Click(object sender, EventArgs e) 1 if (flag = 1 & sp = 0 & max = 0)if (thisnumlnput.Text = 0 )thisnumlnput .Text =;if (eq = 1)this numinput Text = 1; eq = 0;elsethisnumlnput .Text += 1;private void two_Click(object sender, EventArgs e) 2 if (flag = 1 & sp = 0 & max = 0)if (thisnumlnput.Text =0 )
14、thisnumlnput .Text =if (eq = 1)thisnumlnput .Text = 2; eq = 0;elsethisnuminput .Text += 2; /thistxtInput .Text += 2;private void three_Click(object sender, EventArgs e) 3if (flag = 1 & sp = 0 & max = 0)if (thisnuminput .Text = 0)thisnuminput .Text = ”;if (eq = 1)thisnumlnput .Text = 3;eq = 0;elsethi
15、snumInput .Text +=3;/thistxtInput .Text += 3;private void four_Click(object sender, EventArgs e) 1 if (flag = 1 & sp = 0 & max = 0)if (thisnuminput .Text = 0)thisnuminput .Text = ”;if (eq = 1)thisnumlnput .Text = 4;eq = 0;elsethisnuminput .Text 十=4;/ thistxtInput .Text -= 4;private void five_Click(o
16、bject sender, EventArgs e) 5 if (flag = 1 & sp = 0 & max = 0)if (thisnuminput .Text = 0)thisnumlnput .Text =”;if (eq = 1)thisnumlnput .Text = 5;eq = 0;elsethisnumlnput.Text = 5;/ thistxtInput .Text += 5;private void six_Click(object sender, EventArgs e). 6if (flag = 1 & sp = 0 & max = 0)if (thisnuml
17、nput.Text = 0”)thisnumlnput .Text =if (eq = 1)thisnumlnput .Text = 6;eq = 0;elsethisnuminput .Text += 6;this txt Input Te:rt += 6;private void seven_Click(object sender, EventArgs e)/. 7if (flag = 1 & sp = 0 & max = 0)if (thisnumlnput.Text = 0 )thisnumlnput .Text =if (eq = 1)thisnumlnput .Text = 7;e
18、q = 0;private void eightClick(object sender, EventArgs e) 8else thisnuminput .Text += 7;Uhistxtinput .Text -= 7;if (flag = 1 & sp = 0 & max = 0)if (thisnuminput .Text = 0)thisnuminput .Text =if (eq = 1)thisnuminput .Text = 8;eq = 0;elsethisnuminput .Text += 8;/thistxtInput .Text += S;private void ni
19、ght_Click(object sender, EventArgs e) . 9if (flag = 1 & sp = 0 & max = 0)if (thisnumlnput.Text = 0)thisnumlnput .Text = “;if (eq = 1)thisnuminput .Text = 9;eq = 0;elsethisnumInput .Text += 9;/thistxtInput .Text += 9;private void zero_Click(object sender, EventArgs e) 0if (flag = 1 & sp = 0 & max = 0
20、) if (thisnumlnput.Text = 0)thisnumlnput .Text =if (eq = 1)thisnumlnput .Text = 0;eq = 0;elsethisnuminput .Text += 0; thistxtInput .Text += 0;private void dian_Click(object sender, EventArgs e) /小數點 if (flag = 1 & sp = 0 & max = 0)if (eq = 1)this numlnput .Text =eq = 0;elsethis numinput .Text *=/thi
21、stxtInputText +二Sendregionregion三角函數private void sin_Click(object sender, EventArgs e)/ sinif (flag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text); double temp = Math. PI * (numl / 180);thistxtInput.Text += sin( + numl +numl = MathSin(temp);this numinput Text = num 1 ToStringO ;this txt In
22、put Text += num 1 ToStringO ;private void cos_Click(object sender, EventArgs e) cosif (flag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text);double temp = Math. PI * (numl / 180);thistxtInput.Text += cos C + numl +numl = MathCos(temp);this.numlnput.Text = num 1 ToStringO ;private void tan_Cl
23、ick(object sender, EventArgs e)/ tanif (flag = 1 & sp = 0)numl = Convert ToDouble(this numlnput Text);double temp = Math. PI * (numl / 180);thistxtInput.Text += tan(* + numl + )二;numl = MathTan(temp);this nximlnput Text = num 1 ToStringO ;Sendregionregion 幫助private void JPiHiToolStripMenuItem_Click(
24、object sender, EventArgs e)MenuAbout about = new MeniaAbout ();about Show();private void change_Click(object sender, EventArgs e)max = 0;if (flag = l&sp = 0)numl = Convert ToDouble(this numlnput Text);private void 使用手冊ToolStripHenuIteni_Cl.ick(object sender, EventArgs e)numl = -numl;this nximlnput T
25、ext = num 1 ToStringO ;MenuUse use = new MenuUse();use. Show();Sendregionregion 皮膚private void KlToolStripMenuItem_Click(object sender, EventArgs e)skinEngine1SkinFile = ApplicationStartupPath + Calmnessssk;private void 2ToolStripMenuItem_Click(object sender, EventArgs e)skinEngine1SkinFile = ApplicationStartupPath + DeepCyanssk;private void Jti3ToolStripMenuItein_Click(object sender, EventArgs e)skinEngine1SkinFile = ApplicationStartupPath + Eighteenssk;private void /t;4ToolStripMenuItem_Click(object sender, EventArgs e)skinEngine1SkinFile = A
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 環保設備安裝維護服務合同
- 校園餐管理績效評估與持續改進機制
- 傳統工程教育模式的局限性及挑戰
- 健康保險行業理賠數據表
- 互聯網食品銷售平臺合作合同
- 鄉村人口健康需求與風險評估
- 2025年心理學實驗設計與統計分析考試試題及答案
- 2025年人際關系與溝通能力測試試題及答案
- 2025年教師資格證考試試卷及答案
- 2025年健康心理學考研入學考試試卷及答案
- 2025屆重慶市普通高中學業水平選擇性考試預測歷史試題(含答案)
- 人教版小學語文四年級下冊作文范文2
- 大學語文試題及答案琴
- 實驗題(7大類42題)原卷版-2025年中考化學二輪復習熱點題型專項訓練
- CJ/T 362-2011城鎮污水處理廠污泥處置林地用泥質
- 紅十字會資產管理制度
- 2025安全宣傳咨詢日活動知識手冊
- DB31/T 1249-2020醫療廢物衛生管理規范
- 四川省宜賓市翠屏區2025屆數學七下期末綜合測試試題含解析
- 鄉鎮合法性審查工作報告
- 2025年發展對象考試題題庫及答案
評論
0/150
提交評論