Untitled
unknown
plain_text
2 years ago
2.0 kB
6
Indexable
package com.abdullah.modul2; import android.os.Bundle; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; import android.widget.RadioGroup; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { int gajiStatus, gajiGolongan; RadioGroup golongan; CheckBox status; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void hitung (View v){ EditText nama = (EditText) findViewById (R.id.nama); TextView outputNama = (TextView) findViewById (R.id.outputNama); TextView outputStatus = (TextView) findViewById (R.id.outputStatus); TextView outputGol = (TextView) findViewById (R.id.outputGol); String name = nama.getText().toString(); outputNama.setText("Total Gaji Anda "+name); status = (CheckBox) findViewById (R.id.menikah); String statusb = ""; if (status.isChecked()) { gajiStatus = 500000; statusb = (String) status.getText(); } else { statusb = "Belum Menikah"; gajiStatus = 0; } outputStatus.setText("Status Anda "+statusb); golongan = (RadioGroup) findViewById (R.id.rgGolongan); String golb = ""; int gol = golongan.getCheckedRadioButtonId(); if (gol == R.id.rbGolongan1){ gajiGolongan = 1000000; golb = "Golongan 1"; }else if (gol == R.id.rbGolongan2){ gajiGolongan = 2000000; golb = "Golongan 2"; }; int totalGaji = gajiStatus+gajiGolongan; TextView total = (TextView) findViewById (R.id.outputGaji); total.setText(String.valueOf(totalGaji)); outputGol.setText("Golongan Anda "+golb); } }
Editor is loading...