package akdg.weitsai.bmi;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity {
	private EditText editHeight, editWidth;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findViews();
	}

	private void findViews() {
		editHeight = (EditText) findViewById(R.id.edit_height);
		editWidth = (EditText) findViewById(R.id.edit_width);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public void submit(View v) {
		String height = editHeight.getText().toString();
		String width = editWidth.getText().toString();
		if ("".equals(height) | "".equals(width)) {
			showEditNullToast();
		}
	}

	private void showEditNullToast() {
		Toast.makeText(this, "請輸入身高和體重", Toast.LENGTH_SHORT).show();
	}

}

@@ -1099,10 +1099,411 @@
 ();%0A%09%7D%0A%0A
+%09/**%0A%09 *%0A%09 * @param height%0A%09 * @param width%0A%09 * @return%0A%09 */%0A%09private double bmi(String height, String width) %7B%0A%09%09double h = Double.parseDouble(height);%0A%09%09double w = Double.parseDouble(width);%0A%09%09return bmi(h, w);%0A%09%7D%0A%0A%09/**%0A%09 *%0A%09 * @param height%0A%09 * @param width%0A%09 * @return%0A%09 */%0A%09private double bmi(double height, double width) %7B%0A%09%09double bmi = (width / Math.pow(height, 2)) * 10000;%0A%09%09return bmi;%0A%09%7D%0A%0A
 %7D%0A

Add bmi function