好文档 - 专业文书写作范文服务资料分享网站

用JAVA编写计算器程序(模拟Windows计算器)

天下 分享 时间: 加入收藏 我要投稿 点赞

}

// 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); } }

用JAVA编写计算器程序(模拟Windows计算器)

}//key\if(this.keyAvailable&&e.getActionCommand()==\{if(this.dNowInput==0){tf1.setText(\除数不能为零\this.keyAvailable=false;}else{<
推荐度:
点击下载文档文档为doc格式
5d9tj8hxyn00kc51ztsi
领取福利

微信扫码领取福利

微信扫码分享