第一范文网 - 专业文章范例文档资料分享平台

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

来源:用户分享 时间:2025/5/24 6:07:44 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

}

// 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计算器).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5d9tj8hxyn00kc51ztsi_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top