|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
กระทู้ #2760 [Java] (จาก IP: 119.42.76.112)
เกี่ยวกับเครื่องคิดเลขอะครับ
ใครรู้โค๊ดเครื่องคิดเลขบนมือถือบ้างอะคับ(J2ME) ขอความกรุณาด้วยครับ
|
จากคุณ
:
Mirror / drow_zynedrom@hotmail.com [2009-12-09 01:12:01]
|
|
ความคิดเห็น #27657 (จาก IP: 125.24.143.63)
ข้อมูลจาก http://www.cpre.kmutnb.ac.th/projects/widgetapp/ticket/6
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package calculator;
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*;
/** * @author SKTCH */ public class calculator extends MIDlet implements CommandListener{ private Command exitCommand,okCommand,backCommand; private TextField getData1,getData2; private Display display; private Form myForm1,myForm2, myResultForm; private Alert ALert; private ChoiceGroup Choice; private String[] operation = {"+ PLUS","- MINUS","* MULTIPLE","/ DIVIDE"}; public calculator(){ myForm1 = new Form("Calculator"); Choice = new ChoiceGroup("Select",List.EXCLUSIVE); myResultForm = new Form("Result"); getData1 = new TextField("First Number",null,10,TextField.NUMERIC) ; getData2 = new TextField("Second Number",null,10,TextField.NUMERIC) ; okCommand = new Command("OK", Command.ITEM, 1); backCommand = new Command("back",Command.ITEM,1); exitCommand = new Command("Exit", Command.EXIT, 2); myForm1.append(getData1); myForm1.append(getData2); myForm1.append(Choice); Choice.append("+ PLUS",null); Choice.append("- MINUS",null); Choice.append("* MULTIPLE",null); Choice.append("/ DIVIDE",null); //getData.addCommand(okCommand); //getData.addCommand(exitCommand); //getData.setCommandListener(this); } public void startApp() { display = Display.getDisplay(this); //myForm1.append(getData1); //myForm1.append(getData2); myForm1.addCommand(okCommand); myForm1.addCommand(exitCommand); myForm1.setCommandListener(this); display.setCurrent(myForm1); //display.setCurrent(getData); }
public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
public void commandAction(Command command, Displayable screen) { int index; if(command == exitCommand){ destroyApp(true); notifyDestroyed(); } else if(command == okCommand){ int fnumber = Integer.valueOf(getData1.getString()).intValue(); int lnumber = Integer.valueOf(getData2.getString()).intValue(); index = Choice.getSelectedIndex(); if(index==0){ int Sum = fnumber + lnumber ; TextField showData1 = new TextField("Result",new Integer(Sum).toString(),10,TextField.UNEDITABLE); myResultForm.deleteAll(); myResultForm.append(showData1); myResultForm.addCommand(exitCommand); myResultForm.addCommand(backCommand); myResultForm.setCommandListener(this); display.setCurrent(myResultForm); } else if(index==1){ int Subtract = fnumber - lnumber ; TextField showData2 = new TextField("Result",new Integer(Subtract).toString(),10,TextField.UNEDITABLE); myResultForm.deleteAll(); myResultForm.append(showData2); myResultForm.addCommand(exitCommand); myResultForm.addCommand(backCommand); myResultForm.setCommandListener(this); display.setCurrent(myResultForm); } else if(index==2){ int Multiply = fnumber*lnumber ; TextField showData3 = new TextField("Result",new Integer(Multiply).toString(),10,TextField.UNEDITABLE); myResultForm.deleteAll(); myResultForm.append(showData3); myResultForm.addCommand(exitCommand); myResultForm.addCommand(backCommand); myResultForm.setCommandListener(this); display.setCurrent(myResultForm); } if(index==3){ int Divide = fnumber/lnumber ; TextField showData4 = new TextField("Result",new Integer(Divide).toString(),10,TextField.UNEDITABLE); myResultForm.deleteAll(); myResultForm.append(showData4); myResultForm.addCommand(exitCommand); myResultForm.addCommand(backCommand); myResultForm.setCommandListener(this); display.setCurrent(myResultForm); } else if(command == backCommand){ getData1.setString(""); getData2.setString(""); display.setCurrent(myForm1); } } } } |
จากคุณ
:
sup98 [2009-12-09 08:06:45]
|
|
ความคิดเห็น #27658 (จาก IP: 61.19.144.194)
ขอบคุณครับ |
จากคุณ
:
Mirror / drow_zynedrom@hotmail.com [2009-12-09 19:27:09]
|
|
ความคิดเห็น #27659 (จาก IP: 202.28.38.253)
ถ้าแบบคำนวนครั้งเดียวหละครับ แบบว่า 2+3-4*5/6 ละแสดงคำตอบออกมา โดยคำนวนตามลำดับความสำคัญ จาก * / + - ตามลำดับ มีใครพอจะรู้บ้างครับ |
จากคุณ
:
Mirror / drow_zynedrom@hotmail.com [2009-12-09 19:36:31]
|
|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|