0% found this document useful (0 votes)
32 views5 pages

Laporan Praktikum V "Auto Complite, Option Menu, List View"

This document contains the source code for an Android application that calculates the area of basic shapes like triangles and squares. The app contains radio buttons to select the shape, edit texts to enter dimensions, and buttons to trigger the calculation. It displays the calculation steps and result. The app uses basic logic and parsing to calculate areas for triangles by multiplying base and height/2, and for squares by multiplying side lengths.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

Laporan Praktikum V "Auto Complite, Option Menu, List View"

This document contains the source code for an Android application that calculates the area of basic shapes like triangles and squares. The app contains radio buttons to select the shape, edit texts to enter dimensions, and buttons to trigger the calculation. It displays the calculation steps and result. The app uses basic logic and parsing to calculate areas for triangles by multiplying base and height/2, and for squares by multiplying side lengths.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

LAPORAN PRAKTIKUM V Auto Complite, Option Menu, List View

Asisten : 1. 2. Gunawan Arief Rivai Oleh : NAMA NIM KELAS : : : Makbul Halik 60200109048 B1

LABORATORIUM KOMPUTER TERPADU JURUSAN TEKNIK INFORMATIKA FAKULTAS SAINS DAN TEKNOLOGI UNIVERSITAS ISLAM NEGERI ALAUDDIN MAKASSAR 2012

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content"> <RadioButton android:onClick="segitiga" android:id="@+id/rbsgt" android:text="Segitiga"/> <RadioButton android:onClick="persegi" android:id="@+id/rbpsg" android:text="Persegi"/> </RadioGroup> <TextView android:id="@+id/txt1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <EditText android:id="@+id/edt1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/txt2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <EditText android:id="@+id/edt2" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:onClick="proses" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Proses..!" /> <TextView android:id="@+id/txthasil1" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="" /> <TextView android:id="@+id/txthasil2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <TextView android:id="@+id/txthasil3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </LinearLayout>

package com.tugaspraktikum3; import import import import import import import import import import android.R.integer; android.R.string; android.os.Bundle; android.app.Activity; android.view.Menu; android.view.View; android.widget.EditText; android.widget.RadioButton; android.widget.TextView; android.widget.Toast;

public class MainActivity extends Activity { EditText edt1, edt2; TextView txt1, txt2, txthasil, txthasil2, txthasil3; RadioButton segitiga, persegi; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); edt1=(EditText) findViewById(R.id.edt1); edt2=(EditText) findViewById(R.id.edt2); txt1=(TextView) findViewById(R.id.txt1); txt2=(TextView) findViewById(R.id.txt2); txthasil=(TextView) findViewById(R.id.txthasil1); txthasil2=(TextView) findViewById(R.id.txthasil2); txthasil3=(TextView) findViewById(R.id.txthasil3); segitiga=(RadioButton) findViewById(R.id.rbsgt); persegi=(RadioButton) findViewById(R.id.rbpsg); } public void segitiga(View v) { txt1.setText("Alas"); txt2.setText("Tinggi"); } public void persegi(View v){ txt1.setText("Panjang"); txt2.setText("Lebar"); } public void proses(View v) { if ((!segitiga.isChecked()) && (!persegi.isChecked())){ Toast.makeText(this, "Pilih Bangun Datar", Toast.LENGTH_SHORT).show(); } else {

String edit1 = (edt1.getText().toString()); String edit2 = (edt2.getText().toString()); if ((segitiga.isChecked())&&(edit1.equals(""))){ Toast.makeText(this, "Isi Nilai Alas Terlebih Dahulu", Toast.LENGTH_SHORT).show(); edt1.requestFocus(); } else if ((segitiga.isChecked())&&(edit2.equals(""))){ Toast.makeText(this, "Isi Nilai Tinggi Terlebih Dahulu", Toast.LENGTH_SHORT).show(); edt2.requestFocus(); } else if ((persegi.isChecked())&&(edit1.equals(""))){ Toast.makeText(this, "Isi Nilai Panjang Terlebih Dahulu", Toast.LENGTH_SHORT).show(); edt1.requestFocus(); } else if ((persegi.isChecked())&&(edit2.equals(""))){ Toast.makeText(this, "Isi Nilai Lebar Terlebih Dahulu", Toast.LENGTH_SHORT).show(); edt2.requestFocus(); } else { if (segitiga.isChecked()){ float hasil = (Integer.parseInt(edit1))*(Integer.parseInt(edit2))/2; txthasil.setText("Hasil Hitung Luas Segitiga"); txthasil2.setText("("+String.valueOf(edit1)+" * "+String.valueOf(edit2)+") / 2"); txthasil3.setText("Adalah = "+ String.valueOf(hasil)+" cm"); } else if (persegi.isChecked()){ Integer hasil = (Integer.parseInt(edit1))*(Integer.parseInt(edit2)); txthasil.setText("Hasil Hitung Luas Persegi"); txthasil2.setText(String.valueOf(edit1)+" * "+String.valueOf(edit2)); txthasil3.setText("Adalah = "+ String.valueOf(hasil)+" cm"); } } } } }

You might also like