You are on page 1of 1

private EditText a,b,c;

private Button hitung;


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
a=(EditText)findViewById(R.id.alas);
b=(EditText)findViewById(R.id.tinggi);
c=(EditText)findViewById(R.id.luas);
hitung=(Button)findViewById(R.id.hitung);
hitung.setOnClickListener(this);
//hitung.setOnClickListener(this);
}
public void onclick(View v){
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int angka1= Integer.parseInt(a.getText().toString());
int angka2 = Integer.parseInt(b.getText().toString());
int luas = (angka1 * angka2)/2;
c.setText(String.valueOf(luas));

You might also like