Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginStart="8dp"
- android:layout_marginTop="8dp"
- android:layout_marginEnd="8dp"
- android:layout_marginBottom="8dp"
- android:orientation="vertical"
- tools:context=".MainActivity">
- <EditText
- android:id="@+id/gaji"
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:hint="Penghasilan/Gaji per Bulan" />
- <EditText
- android:id="@+id/lain"
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:hint="Penghasilan lainnya per Bulan" />
- <EditText
- android:id="@+id/hutang"
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:hint="Cicilan/Hutang per Bulan" />
- <EditText
- android:id="@+id/beras"
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:layout_marginBottom="20dp"
- android:hint="Harga beras saat ini" />
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="20dp"
- android:onClick="hitung"
- android:text="Hitung" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:text="Total Pendapatan"
- android:textSize="18dp" />
- I
- <TextView
- android:id="@+id/pendapatan"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="18dp"
- android:text="0"
- android:textSize="18dp" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:text="Nishab Zakat"
- android:textSize="18dp" />
- I
- <TextView
- android:id="@+id/nishab"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="18dp"
- android:text="0"
- android:textSize="18dp" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:text="Zakat yang harus dikeluarkan /bulan"
- android:textSize="18dp" />
- <TextView
- android:id="@+id/total"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="0"
- android:textSize="24dp" />
- </LinearLayout>
- public class MainActivity extends AppCompatActivity {
- EditText edGaji, edLain, edHutang, edBeras;
- TextView tvNishab, tvTotal, tvPendapatan;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- edGaji = findViewById(R.id.gaji);
- edLain = findViewById(R.id.lain);
- edHutang = findViewById(R.id.hutang);
- tvPendapatan = findViewById(R.id.pendapatan);
- edBeras = findViewById(R.id.beras);
- tvNishab = findViewById(R.id.nishab);
- tvTotal = findViewById(R.id.total);
- }
- public void hitung(View view) {
- double vGaji, vLain, vHutang, vZakat,
- vBeras, vHasil, vNishab;
- vGaji = Double.parseDouble(
- edGaji.getText().toString());
- vLain = Double.parseDouble(
- edLain.getText().toString());
- vHutang = Double.parseDouble(
- edHutang.getText().toString());
- vBeras = Double.parseDouble(
- edBeras.getText().toString());
- vHasil = vGaji + vLain - vHutang;
- vNishab = 522 * vBeras;
- vZakat = vHasil * 0.025;
- tvPendapatan.setText(
- Double.toString(vHasil));
- tvNishab.setText(
- Double.toString(vNishab));
- if(vHasil > vNishab){
- tvTotal.setText(
- Double.toString(vZakat));
- }else{
- tvTotal.setText(
- "Anda Tidak Wajib Membayar" +
- "Zakat");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement