Anyone can help me in this Java ME coding
Anyone help me please... Need Help....
/*
* bmi.java
*
* Created on June 17, 2007, 9:54 PM
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author alpharif
* @version
*/
publicclass bmiextends MIDlet
{
private Display display;
private Command cmdExit;
private Command cmdCalculate;
private Command cmdOK;
private Form bmiInput;
private Form bmiOutput;
private TextField txtWeight;
private TextField txtHeight;
private StringItem bmiresult;
publicvoid startApp ()
{
display = Display.getDisplay (this);
cmdCalculate =new Command ("Calculate", Command.SCREEN, 1);
cmdExit =new Command ("Exit", Command.SCREEN, 1);
cmdOK =new Command ("OK", Command.SCREEN, 1);
bmiInput =new Form ("BMI Input");
txtWeight =new TextField ("Weight :", null, 5, TextField.DECIMAL);
bmiInput.addCommand (cmdCalculate);
bmiInput.addCommand (cmdExit);
bmiInput.setCommandListener (this);
bmiInput.append (txtWeight);
txtHeight =new TextField ("Height :", null, 5, TextField.DECIMAL);
bmiInput.append (txtHeight);
bmiOutput =new Form ("BMI Result");
bmiresult =new StringItem (null,null);
bmiOutput.append (bmiresult);
bmiInput.addCommand (cmdOK);
bmiInput.setCommandListener (this);
display.setCurrent (bmiInput);
}
publicvoid pauseApp ()
{
}
publicvoid destroyApp (boolean unconditional)
{
}
publicvoid commandAction(Command cmd, Displayable d)
{
String displayString =null;
if (cmd == cmdExit)
{
destroyApp (false);
notifyDestroyed();
}
elseif (cmd == cmdCalculate)
{
Double height;
Double weight;
Double calc;
weight = txtWeight;
height = txtHeight;
//displayString = calculateBMI (weight, height);
calc = height * weight;
displayString = calc.toString();
bmiresult.setText (displayString);
display.setCurrent (bmiOutput);
}
elseif (cmd == cmdOK)
{
txtWeight.setString (null);
txtHeight.setString (null);
display.setCurrent (bmiInput);
}
}
This is the error generated by netbeans 5.5.1
C:\Documents and Settings\alpharif\My Documents\My Projects\bmi\src\bmi.java:39: setCommandListener(javax.microedition.lcdui.CommandListener) in javax.microedition.lcdui.Displayable cannot be applied to (bmi)
bmiInput.setCommandListener (this);
C:\Documents and Settings\alpharif\My Documents\My Projects\bmi\src\bmi.java:48: setCommandListener(javax.microedition.lcdui.CommandListener) in javax.microedition.lcdui.Displayable cannot be applied to (bmi)
bmiInput.setCommandListener (this);
C:\Documents and Settings\alpharif\My Documents\My Projects\bmi\src\bmi.java:77: incompatible types
found: javax.microedition.lcdui.TextField
required: java.lang.Double
weight = txtWeight;
C:\Documents and Settings\alpharif\My Documents\My Projects\bmi\src\bmi.java:78: incompatible types
found: javax.microedition.lcdui.TextField
required: java.lang.Double
height = txtHeight;
C:\Documents and Settings\alpharif\My Documents\My Projects\bmi\src\bmi.java:82: operator * cannot be applied to java.lang.Double,java.lang.Double
calc = height * weight;
5 errors
C:\Documents and Settings\alpharif\My Documents\My Projects\bmi\nbproject\build-impl.xml:183: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

