Membuat Aplikasi Luas Segitiga
public class MainActivity extends AppCompatActivity { Double alas,tinggi,luas; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void hitung (View view) { EditText edtAlas = (EditText)findViewById(R.id.edtAlas); EditText edtTinggi = (EditText)findViewById(R.id.edtTinggi); TextView txtHasil = (TextView)findViewById(R.id.txtHasil); alas = Double.parseDouble(edtAlas.getText().toString()); tinggi = Double.parseDouble(edtTinggi.getText().toString()); luas = alas*tinggi/2; txtHasil.setText("Luas segitiga = alas x tinggi = " + luas); } }