C#编程科学计算器_第1页
C#编程科学计算器_第2页
C#编程科学计算器_第3页
C#编程科学计算器_第4页
C#编程科学计算器_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、usi n g Sy s t e m;usin g Sy s tem。 Co llections.G e ne ric; usi ng System。 ComponentMo del;u s in g Sy s tem、D ata;usi ng System 、 Drawi ng ;usi ng Sys tem。 Text;u si ng S ystem、W ind o ws。Form s ;n am espace Calcu 1 at oru b l i c par t ia 1 class Coun ter : F o r mpublicC o un t er()I nitiali zeC

2、om pon e nt ();doublenum 1 ,nu m2;d o ube resu It =0 ;intintintinto p;f lag =0 ; /开始标志sp = 0; /判断除数为零时移除监听maX =0 ;/ 范围标识in t eq= 0 ;region privat功能键v o i d on_CIick(o b je c t sender,Eve ntArgs e) / /开始f la g = 1;= 0;0;maprivths。flasp =m axnus。vomI nput 。 txtInput 、i d o ff_Cg =0;0;= 0;t h is 。priv

3、a tT extText = "max =if (f0;10i ck( o bjects e n de r ,E ventArgs e) / /关闭、numln put。Text =" tx t Inpu t .TeX tvo id button9_Click(ag = 1 &sp=0)ob je ctsen d er,Eve n t Ar gs e) / 删除string num s tr i ng = ( nu mstr ing.t hi s、numl npu t.Tex t ;Le ngth > 0)stringt e mp=numstring o S

4、ubstring( 0 , numst r ing、 Length 1);th i Sonumlnpu t、Tex t = temp、T oS t r i ng();rivaifelth i s、numInpu to Text =d clear_CI i ck( object send ema x = 0;(flag =1)privatmaxif#end0"r , E ventArgs e) /c 清零s p = 0;t his on um lnput o Text = th is .txtInputo Text ="0" ;”vo id d e le t e C

5、 lick (o b jectsen der, Eve nt Args e ) / 清零0;(flag = = 1)sp= 0;hi s、numl nput oTe xt ="0" ;reg ionr egiprivateonvoid运算符e qu al C1 ic k ( objects e nder,Eve ntA rg s e )/ 等号q = 1;if (flag = 1 & & sp = 0)max =0 ;Conve rt o ToD ouble( this onum 2th i so txthis .txtlnput InPuto Te xt

6、+= num2o to Text += "=”;n uml nput、Text);ToStr ing();tx t lnput、 Text = nu ll ;s wit c h (op)case 1: r e sul tn um1 + num2;b r e ak ;c ase 2: re s ult = num1um 2;b rea k ;ca se 3: r esult = numum 2;b reak;case 4:re sun um1/ num2;break;c a se 5: result=Math。Pow(nu m1, nu m2 );br eak ;case 6: re

7、s ult=Mod(nu m 1, num2);b reak;defau 1 t: re tur n ;if(o p = = 4 && num2 = 0)/this 、t xtInpu this 、 numIn put.Texpr iV ate vo i d sub_Click(object sende r , Ev ent Ar gs e) / 减法t h i s .n u ml npu t。Text ="除数不能为 0" sp = 1;e lset、T ext += result 、To Strin g (); t = r esult 、 ToStr i

8、ng();m aX =0;(flag = = 1 & & sp = 0)n um1 = Convert、 ToDoubl e (this 。 numInput.Text); t his . t xtInput.T e xt+= num1 、To String();T ext +=n u mInput。 TeXt his 、 t X tInput 、o p = 2;ivatevoi d mul_Click(object send e r, Eve ntArg s e )/ 乘法X = 0;if(f1a g = 1&& sp=0)num1C on V ert、T o

9、 Do u b le( this、nu ml n p ut。Te x t);t hi s、 t x tinpu t。 Text +=num1。 ToStri n g();this .n u minp ut。 Textext +=th i s、 txtinp u t、To p = 3;pr ivatevoi d di vide_Click(ob j e Cts ender, Eve ntArgs e) / 除法max =(fag = 1&& s p = = 0)nu m 1C onv e r t、T oDouble(thithit x tinput.Te n umI nput。x

10、t += nH »Tex t =t his。numl nput.Te xt ); u ml、ToStri ng();thopo t xt I nput、Text += "/ ”=4 ;priV a tevoidplus_ C liCk(objeC ts en der, Event Args e)/ 加法ax0;(fag = = 1 & sp = = 0)n um1 =Conve rt。T o Dout h is .txtInput、 min put .Text txti n put.TeText + =b le( this .numinp u t.T e xt );

11、T oStr i ng();num1。”;x t+=”+op= 1;p ub licd ouble Mod( d oub le x,d oue y)/ 取模运算max = 0;eturnt emp = Convert 、 (xy* tem p);ToInt3(x / y);prte voi d p o we r _Cl ick( objCtsend er, EVe ntArgs e) / 幂运算ifm ax =0;(fl a g = 1 & s p = 0)num1 = Convert oT oDoubthis 、t xtInput.Text += nule(num I npu t。T

12、ex t); m 1.To S tr i ng ();th i s。numinpu t。Textthi s o txt I npu t、Text + op = 5;privateif (privatemavoid re c ip_ C li c k(objemax = 0;ifCtse nd er,E ventAr g s e) / 倒数f lag = = 1 & & s p =0)nu ml = Co nv er t .T oD ouble( t h i d oub le temp = 0;t e mp = 1 / n uml ;t hi Sot X t In pu t.Te

13、xt t h is o nmln put、void p erc= 0;(flag = 1 &/dou b l/thi sn t_C sps .nu m Input、Text);=l”Text = tem p、 ToSt ring();+ num1、T oStri ng () + "= ”oplick(objec t se n der, Even tArgs e)0)t emp、 t X tInpe mp / l 00;u t.o nv ert oT oD oub le(this.numi n pu t. Text);Tex t += t emp。To Stri n g();/

14、temp = t/this o numInput、 Text = temp.ToStri ng();/t his.tx t Input .Text = ”=” ; num1 = Convert.ToDouble( t his.numInpu t、 T eXt); th i sot xt I nput、T ext += nu m 1oT oSt rin g();thiso numInput、 TeXt = "th i s、 txtIn p ut、 Text += "”;= 6; end reg iogiate#reonp ri vvo i数字d o n e_Click( o

15、b j ect sender , Even t Args e) / /1(flag = 1&& sp = = 0 &&max = 0)i f ( th i。numlnp u t.T e x t ="0" )t hi。 numInp ut。 TeX t =f ( eq =1)priV ateifivt h is .numlnput. Tex t = eq = 0;elset h is . n umlnput.Text+=Vo(flag"1"1 ”IIi d tw(t hio Cli ck( o b j&& s

16、 p = 0s.numlnp u t.Textct send er,& & ma x = ” 0” )EventA r gs e ) 112t hi s . n uml npu t。Teif (eq = 1)sext =”thi s on umlnp ut.Text =0;、 numlnput、/this.txtlnthise void thr2"Text + = "2" ; ut o Text + = "2”ee_Cl ick( ob j ect s ende r,EventArgs e) /3if (lag =&& s

17、 p =0&&ma x = = 0)if(th i s。numi nput。Text0 ")this .n umI np ut、T ex tif (e q = 1)II3”this .numInp ut.Text =eq = 0 ;elthis .nu m lnput.Text = ” 3” /this 、t xtlnput o Text + =II3 "p rivate vo i d four _ Cl i c k( object se nd er, Ev en t Args e) /4(f 1 ag = 1 && sp =0&&a

18、mp; m ax = = 0)(thi s。num Input、Text =”0”)this o numInp uto Text = ”(eq = 1)"4 ”thi S.n um In p ut.Text =0 ;elsethis.numInput 、 Te xt +=Te xt/ t h i s、 tX tIn p uto”4" = ”4 "ivate VO idfive_Click(objec t send er, EventArgs e) /5if (flag =1 & & sp= 0 & max = 0)t his。numInp

19、ut、T e X t =”0his.n u mln put oTexif(eq= 1)s、 numInpu t、 Text = eq = 0;thi"5elset his 、 numInpu to TeX t + = ” /this ot xt I nput .Text = ”5 ";p rivae void six_CI i ck( o b ject s ender,E ventAr g s e )/ 6ifla g=1 && sp = =0 && ma X= 0)0 ")( t hi s o numInput.Tex t =th

20、is on umInpu t.Te X t =""1)if (eq" 6”lses.numInputo Text + = "6”/this.txt In put、Text += "6P riat eV oids eVen_Click( obj e c tsend e r, E ventArg s e) /7if1 ag=1 & & sp&& max = = 0)if (t hi s。numinpu t、Te x t" 0")his 、 numInput.Textifeq= 1 )this .n

21、umInp u t 、 Tex t =0;eqelseth is 、num Inut oT ext +=7"/thixtnPu t 、 Tex t”7"privae voideig h t_C1 ick( obje ct s e nd e r, E ventAr g s e)/8(fla g = 1 sp = 0 && max=0)ifh is onumInput. T ext = = "0")ths、 nu mInput.Tex t =HHth i s.n umInput、 Text =eq =0;" 8"8(e q

22、 =1 )his 、 numInp u t.Text =eq= 0;els ethis .numInput o Te xt ="Pu t o Text +=/th i s、 txtInva t ev o id n igh t _Cl i ck( o bject sen der, Event Ar gs e) /9P riprivateif (flififiva g = 1&& sP = 0&& ma x = 0)ifhis .numinP ut、 Text = ”0”t his、n uml nput、T ex t =q = 1)th i s。 nu m

23、I nput 、 eq =0 ;Text =els eth i s . n uminput、 Text +=”9"/thivoi d(flagifSo txt I np ut oText += 9"HHII9”ze r o_C l i c k ( object sen der,= 1 && sp = = 0 max =(t h is、n u mln put o Text =t his .numinP ut、 Text =IIf (eq = = 1 )th is on umln p ut o eq = 0;TextEventAr g s e) / 00)0II

24、elsthis o/thnu minpu to Text = ” so tx tI npu t 、T ext += "00”t e voi d di a n_CI i ck (object s e nd er,(fag = = 1 & sp =0 & max(e=1)t hi s.numinput、TextIIEventArgs e) / 小数点= 0)this .n/t he q = 0;u mI nput、 TeX t +=”oi so tX tInp u t、T eX t += " o "end r e gion三角函数#reg io npr

25、iVatVO i d sin_ C li c k( objec t send er ,EV en t Argse) /s i nprpri(fl ag = = 1 && sp =num1do uble t et h is .t Xn um1 =To Doubl e(th mp = Math 、PI * (nu tI n pu t 、 TeX t += "si M at ho Sin(temp);= n um1o ToString(); num1、 ToString();C onVert 、i s.numInput o m 1 18 0); n(” + n um1e x

26、 t ); ” ) =this . n umInput.T e xt/t h is ot xt In p uto TeX t +=a t e void c os_ Click( ob j ect sen de r, Event A r g sif (fla g = = 1& &s p = = 0)num 1doublehis 、tXn um1 =th)/ cosConvert 、 ToDo ubl e (this .numIn put.Tex temp =Math 、PI (n u m1 18 0);tI np ut.Text = ”c os( + nu m 1 +)=&quo

27、t; ;M atht );ati s .num Ioi d ta n、Cos(temp);npClut、T extnu m1o ToString();ick( o b j ect sen de r, EV entAr gs e )/ t anif(flag = 1&&s p = = 0)num1doubthi s、num1 =h isCon vert . T o D o u b l e(this . n letemp = Math、 tX tIn pu t o Text Math.Tan(t emp);、numI nput 、T ext =PI+= ”umInpu t 、TeX

28、 t);(num1ta n(" +n um1 ToStrend region/ 18 0);num1 + ) =ing();reg ion 帮助pr ivat e v oid 关于产品 Tool Stri pMen uI tem_CliEventArgs e)ck ( o b j e ctse nder,MenuAbout about = ne w Me nuAbout();how ();about、Sivatmaxifvoi(fl anum1numprivat een tAr gs e )d Chan g e_C l ick (obj ect send er,Ev entArgse

29、)0;g = = 1 & &sp = = 0)1= Con vert oT oDo ub 1 e(this、= nu m1;thi s .numI nput°Tex t= numnumInput 。Text);T oString();v oid 使用手册 Tools trip M en u I t em _C 1 ic k (object sende r,EvMen uUs e us e = new Me nu Use(); u seoS ho w();end regi o n regio np riv ate皮肤void皮肤 1Too lS t ripMe n uI

30、 tem _Clic k (obj ec t s ender,EventArgs e )s ki nEngine1。Sk in File = Ap pli c at i on、Sta r tup P ath + "Cal m ness、 sskpriva tevoid皮肤2 ToolSt r ip M enu ltem_Clic k (obj ec t s e n de r ,Ev entAg s e)k”rientArgsen。 ssk" ;s k inEnv at e ve)skinEng ine1 、S kinFileoi d 皮肤3 Toolg ine1.Ski n Fileprivate void 皮肤4 ToolStrip= Applic a tion 、St artupP a th +St ripMe nuI te m _C lick( ob j=Ap pli c ati o n、St ar tupP a tMe nuI t em _Cli c k( objec tect sD eepCy ae nder, Eh + " Ei g hts

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论