Android BMI calculation in CM and KG
<p>hye, i want to create BMI simple android application. i found this code but this code calculate in LBS and also INCH. but, my program need to create in KG and also CM. i already try to recode back. but, i still cant find the solution. </p>

<p>this is the code.</p>

<pre><code>package com.example.bmicalculator;

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
    import android.widget.EditText;
    import android.widget.Button;
    import android.view.View;

    public class BMICalculatorActivity extends Activity {

    private EditText txtheight;
    private EditText txtweight;
    private TextView txtresult;
    private Button btncalculate;
    private double bmi = 0;
    private double valueheight = 0;
    private double valueweight = 0;
    private String resulttext;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        initControls();
        /*TextView tv = new TextView(this);
        tv.setText("BMI Calculator");
        setContentView(tv);*/

   }


    private void initControls() {
        txtheight = (EditText)findViewById(R.id.txtheight);
        txtweight = (EditText)findViewById(R.id.txtweight);
        txtresult = (TextView)findViewById(R.id.txtresult);
        btncalculate = (Button)findViewById(R.id.btncalculate);
        //btnreset = (Button)findViewById(R.id.btnreset);
        btncalculate.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ calculate(); }});
        //btnreset.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ reset(); }});
    }

    private void calculate()    {
        valueheight =Double.parseDouble(txtheight.getText().toString());
        valueweight =Double.parseDouble(txtweight.getText().toString());
        bmi = (valueweight / (valueheight * valueheight));
        //txttipamount.setText(Double.toString(bmi));
        if (bmi &gt;= 30) { /* obese */
            resulttext = "Your BMI of " + Double.toString(bmi) + " is OBESE.";
            txtresult.setText(resulttext);
        } else if (bmi &gt;= 25) {
            resulttext = "Your BMI of " + Double.toString(bmi) + " is OVERWEIGHT.";
            txtresult.setText(resulttext);
        } else if (bmi &gt;= 18.5) {
            resulttext = "Your BMI of " + Double.toString(bmi) + " is IDEAL.";
            txtresult.setText(resulttext);
        } else {
            resulttext = "Your BMI of " + Double.toString(bmi) + " is UNDERWEIGHT.";
            txtresult.setText(resulttext);
        }
    }
    private void reset()
    {
        txtresult.setText("Your BMI is unknown.");
        txtheight.setText("0");
        txtweight.setText("0");
    }



}
</code></pre>

<p>thanks in advance.</p>
