siResult.setText("Result: " + res); tfNumber1.setString(""); tfNumber2.setString(""); tfNumber1.setVisible(true); tfNumber2.setVisible(false); isNumber1 = true; } else if (c == cmdExit) { destroyApp(true); } } });
form.addCommand(cmdAdd); form.addCommand(cmdSub); form.addCommand(cmdMul); form.addCommand(cmdDiv); form.addCommand(cmdEq); form.addCommand(cmdExit); nokia dct4 calculator
if (operator.equals("+")) { res = n1 + n2; } else if (operator.equals("-")) { res = n1 - n2; } else if (operator.equals("*")) { res = n1 * n2; } else if (operator.equals("/")) { if (n2 != 0) { res = n1 / n2; } else { siResult.setText("Result: Error"); return; } } siResult
import javax.microedition.lcdui.*; import javax.microedition.midlet.*; siResult.setText("Result: " + res)