计算器实现.doc
上传人:sy****28 上传时间:2024-09-10 格式:DOC 页数:4 大小:39KB 金币:16 举报 版权申诉
预览加载中,请您耐心等待几秒...

计算器实现.doc

计算器实现.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

16 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

importjavax.microedition.midlet.MIDlet;importjavax.microedition.midlet.MIDletStateChangeException;importjavax.microedition.*;importjavax.microedition.lcdui.Alert;importjavax.microedition.lcdui.AlertType;importjavax.microedition.lcdui.Command;importjavax.microedition.lcdui.CommandListener;importjavax.microedition.lcdui.Display;importjavax.microedition.lcdui.Displayable;importjavax.microedition.lcdui.Form;importjavax.microedition.lcdui.Item;importjavax.microedition.lcdui.ItemCommandListener;importjavax.microedition.lcdui.StringItem;importjavax.microedition.lcdui.TextBox;importjavax.microedition.lcdui.TextField;importjavax.microedition.midlet.*;importjavax.microedition.midlet.MIDlet.*;publicclassShow_CalcextendsMIDletimplementsCommandListener,ItemCommandListener{privateDisplaydisplay;privateFormform;intF=1;doublee=0.0,result=0.0;Stringdown=null;TextFieldtb=newTextField("计算器实现",null,15,TextField.DECIMAL);privateCommandexitCommand=newCommand("退出",Command.EXIT,1);privateCommandshowCommand=newCommand("取消",Command.SCREEN,2);privateCommandCommand1=newCommand("",Command.ITEM,2);privateCommandCommand2=newCommand("",Command.ITEM,2);privateCommandCommand3=newCommand("",Command.ITEM,2);privateCommandCommand4=newCommand("",Command.ITEM,2);privateCommandCommand5=newCommand("",Command.ITEM,2);privateAlertalert;publicShow_Calc(){display=Display.getDisplay(this);form=newForm("计算器的实现");StringItemitem0=newStringItem(null,"请输入参与计算的每一项");form.append(item0);form.append(tb);StringItemitem1=newStringItem(null,"+",Item.BUTTON);StringItemitem2=newStringItem(null,"-",Item.BUTTON);StringItemitem3=newStringItem(null,"*",Item.BUTTON);StringItemitem4=newStringItem(null,"/",Item.BUTTON);StringItemitem5=newStringItem(null,"指数次幂",Item.BUTTON);item1.setDefaultCommand(Command1);item2.setDefaultCommand(Command2);item3.setDefaultCommand(Command3);item4.setDefaultCommand(Command4);item5.se