📄 +
字号:
<BR>{<BR>n=0;<BR>a=false;<BR>switch(symbol)<BR>{<BR>case
'+':<BR>y=y+x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'-':<BR>y=y-x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'*':<BR>y=y*x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'/':<BR>if(x!=0)<BR>{<BR>y=y/x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>}<BR>else<BR>result.setText("Error");break;
<BR>default: break; <BR>}<BR>b=true;<BR>symbol='\0';<BR>x=y; <BR>}
<BR>if(e.getSource()==btnce)
<BR>{<BR>x=0;<BR>result.setText("0.0");<BR>b=false;<BR>a=false;<BR>n=0;<BR>}
<BR>if(e.getSource()==btnbak)
<BR>{<BR>if(a==false)<BR>{<BR>x=((int)x)/10;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>else<BR>{<BR>n--;<BR>t=t.substring(0,t.length()-1);<BR>if(n==0)<BR>{<BR>x=(int)(x*Math.pow(10,n))/(Math.pow(10,n));<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(t+"0");<BR>}<BR>else
<BR>{<BR>x=(int)(x*Math.pow(10,n))/(Math.pow(10,n));<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(t);<BR>}<BR>if(n==0)<BR>a=false;<BR>}<BR>}
<BR>if(e.getSource()==btnd)
<BR>{<BR>if(x!=0)<BR>{<BR>y=1/x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>x=y;<BR>b=true;<BR>}<BR>else<BR>result.setText("Error");<BR>}
<BR>if(e.getSource()==btnmd)
<BR>{<BR>x=x/100;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>a=true;<BR>n+=2;<BR>t=String.valueOf(x);<BR>}<BR>if(e.getSource()==btnrev)
<BR>{<BR>if(x!=0)<BR>{<BR>x=-x;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}
<BR>}<BR>if(e.getSource()==btnsqrt)
<BR>{<BR>if(x>=0)<BR>{<BR>y=Math.sqrt(x);<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>b=true;<BR>x=y;<BR>}<BR>else<BR>result.setText("Error");<BR>}
<BR>}<BR>public boolean keyDown(Event evt,int
key)<BR>{<BR>PressKey=(char)key;<BR>switch(key)<BR>{<BR>case
'0':<BR>if(n==0)<BR>t=String.valueOf(x);<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{<BR>x*=10;<BR>result.setText(String.valueOf(x));<BR>}<BR>else<BR>{<BR>++n;
<BR>if(n>1)<BR>t=t+"0";<BR>result.setText(t);<BR>}<BR>t=String.valueOf(x);<BR>break;<BR>case
'1':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{<BR><BR>x=x*10+1;
<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{
<BR>++n;<BR>x=x+Math.pow(10,-n)*1;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);<BR>break;<BR>case
'2':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{
<BR>x=x*10+2;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*2;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);<BR>break;<BR>case
'3':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{
<BR>x=x*10+3;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*3;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);
<BR>break;<BR>case
'4':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{<BR>x=x*10+4;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*4;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);<BR>break;<BR>case
'5':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{
<BR>x=x*10+5;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*5;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);<BR>break;<BR>case
'6':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{
<BR>x=x*10+6;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*6;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);<BR>break;<BR>case
'7':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{
<BR>x=x*10+7;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*7;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);
<BR>break;<BR>case '8':<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{
<BR>x=x*10+8;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*8;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);
<BR>break;<BR>case
'9':<BR>if(n==0)<BR>t=String.valueOf(x);<BR>if(b==true)<BR>x=0;<BR>if(a==false)<BR>{
<BR>x=x*10+9;<BR>result.setText(String.valueOf(x));<BR>b=false;<BR>}<BR>else<BR>{<BR>++n;<BR>x=x+Math.pow(10,-n)*9;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>t=String.valueOf(x);
<BR>break;<BR>case '.':<BR>a=true;<BR>break;<BR>case
'+':<BR>n=0;<BR>a=false;<BR>if(symbol=='\0')<BR>{ <BR>y=x;
<BR>}<BR>else<BR>{<BR>switch(symbol)<BR>{<BR>case
'+':<BR>y=y+x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'-':<BR>y=y-x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'*':<BR>y=y*x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'/':<BR>if(x!=0)<BR>{<BR>y=y/x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>}<BR>else<BR>result.setText("Error");break;
<BR>default: break; <BR>}<BR>}<BR>b=true;<BR>symbol='+'; <BR>x=y;
<BR>break;<BR>case '-':<BR>n=0;<BR>a=false;<BR>if(symbol=='\0')<BR>{
<BR>y=x;<BR>}<BR>else<BR>{<BR>switch(symbol)<BR>{<BR>case
'+':<BR>y=y+x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'-':<BR>y=y-x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'*':<BR>y=y*x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'/':<BR>if(x!=0)<BR>{<BR>y=y/x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>}<BR>else<BR>result.setText("Error");break;
<BR>default: break; <BR>}<BR><BR>}<BR>b=true;<BR>symbol='-';<BR>x=y;
<BR>break;<BR><BR>case '*':<BR>n=0;<BR>a=false;<BR>if(symbol=='\0')<BR>{
<BR>y=x;<BR>}<BR>else<BR>{<BR>switch(symbol)<BR>{<BR>case
'+':<BR>y=y+x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'-':<BR>y=y-x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'*':<BR>y=y*x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'/':<BR>if(x!=0)<BR>{<BR>y=y/x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>}<BR>else<BR>result.setText("Error");break;
<BR>default: break; <BR>}<BR>}<BR>b=true; <BR>symbol='*';<BR>x=y;
<BR>break;<BR>case
'/':<BR>n=0;<BR>a=false;<BR>if(symbol=='\0')<BR>{<BR>y=x;<BR>}<BR>else<BR>{<BR>switch(symbol)<BR>{<BR>case
'+':<BR>y=y+x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'-':<BR>y=y-x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'*':<BR>y=y*x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'/':<BR>if(x!=0)<BR>{<BR>y=y/x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>}<BR>else<BR>result.setText("Error");break;
<BR>default: break; <BR>}<BR>}<BR>symbol='/';<BR>b=true;<BR>x=y; <BR>break;
<BR>case Event.ENTER:<BR>n=0;<BR>a=false;<BR>switch(symbol)<BR>{<BR>case
'+':<BR>y=y+x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'-':<BR>y=y-x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'*':<BR>y=y*x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>break;<BR>case
'/':<BR>if(x!=0)<BR>{<BR>y=y/x;<BR>y=((double)Math.round(y*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(y));<BR>}<BR>else<BR>result.setText("Error");break;
<BR>default: break; <BR>}<BR>b=true;<BR>symbol='\0';<BR>x=y; <BR>break;<BR>case
Event.BACK_SPACE:<BR>if(a==false)<BR>{<BR>x=((int)x)/10;<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(String.valueOf(x));<BR>}<BR>else<BR>{<BR>n--;<BR>t=t.substring(0,t.length()-1);<BR>if(n==0)<BR>{<BR>x=(int)(x*Math.pow(10,n))/(Math.pow(10,n));<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(t+"0");<BR>}<BR>else
<BR>{<BR>x=(int)(x*Math.pow(10,n))/(Math.pow(10,n));<BR>x=((double)Math.round(x*(1e+13)))/(1e+13);<BR>result.setText(t);<BR>}<BR>if(n==0)<BR>a=false;<BR><BR>}<BR>break;<BR>case
Event.HOME:<BR>symbol='\0';<BR>x=0;<BR>y=0;<BR>n=0;<BR>a=false;<BR>b=false;<BR>result.setText("0.0");<BR>break;<BR>default:<BR>return(false);<BR>}<BR>repaint();<BR>return
true;<BR>}<BR>} </FONT></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -