}
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
if(this.dNowInput==0) {
tf1.setText(\除数不能为零\ this.keyAvailable=false; } else {
this.dNowInput=1/this.dNowInput;
tf1.setText(Double.toString(this.dNowInput)); } }
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
this.alreadyClickedEqueal=true; switch(this.nOperation) {
case 1: this.dResult+=this.dNowInput; break; case 2: this.dResult-=this.dNowInput; break; case 3: this.dResult*=this.dNowInput; break; case 4: {
if(this.dNowInput==0) {
tf1.setText(\除数不能为零\ this.keyAvailable=false;
}
else this.dResult=this.dResult/this.dNowInput; } }
if(this.keyAvailable)tf1.setText(Double.toString(this.dResult)); }
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
this.dMemory=this.dNowInput; if(this.dMemory!=0) tf2.setText(\ }
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
this.dMemory=0; tf2.setText(\ }
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
this.dNowInput=this.dMemory;
tf1.setText(Double.toString(this.dNowInput)); }
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
this.dMemory+=this.dNowInput; if(this.dMemory!=0)
tf2.setText(\ else tf2.setText(\ }
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
this.dNowInput=(this.dResult*this.dNowInput)/100; tf1.setText(Double.toString(this.dNowInput)); }
// key \
if(this.keyAvailable && e.getActionCommand()==\ {
if(!this.alreadyClickedEqueal){ if(this.dNowInput!=0) {
if(this.alreadyHaveDot) {
if(this.n==-1) {
this.alreadyHaveDot=false; this.n=0; } else {
String str,str1; str=tf1.getText();
str1=str.substring(0,this.nBitsNum-1); this.nBitsNum--; this.n++;
this.dNowInput=Double.parseDouble(str1);
tf1.setText(Double.toString(this.dNowInput)); } } else { int temp;
temp=(int)(this.dNowInput/10); this.dNowInput=(double)temp;
tf1.setText(Double.toString(this.dNowInput)); } } } } }
public static void main(String args[]) {
Calculation cal=new Calculation(); cal.display(); }
public void windowClosing(WindowEvent e) {
System.exit(0); } }