SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.lingkaran;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4. import android.view.View;
  5. import android.widget.EditText;
  6. import android.widget.Button;
  7.  
  8. import android.os.Bundle;
  9.  
  10.  
  11. public class MainActivity extends AppCompatActivity {
  12.     private EditText a;
  13.     private EditText b;
  14.     private EditText editTextLuas;
  15.     private Button buttonHitungLuas;
  16.  
  17.  
  18.     @Override
  19.  
  20.     protected void onCreate(Bundle savedInstanceState) {
  21.         super.onCreate(savedInstanceState);
  22.         setContentView(R.layout.activity_main);
  23.  
  24.         initUI();
  25.         initEvent();
  26.     }
  27.  
  28.     private void initUI() {
  29.         a = (EditText) findViewById(R.id.edit1);
  30.         b = (EditText) findViewById(R.id.edit2);
  31.         editTextLuas = (EditText) findViewById(R.id.editTextLuas);
  32.         buttonHitungLuas = (Button) findViewById(R.id.buttonhitungluas);
  33.     }
  34.  
  35.     private void initEvent() {
  36.         buttonHitungLuas.setOnClickListener(new View.OnClickListener() {
  37.             @Override
  38.             public void onClick(View view) {
  39.                 hitungluas();
  40.             }
  41.         });
  42.     }
  43.  
  44.     private void hitungluas() {
  45.         int Sisi1 = Integer.parseInt(a.getText().toString());
  46.         int Sisi2 = Integer.parseInt(b.getText().toString());
  47.         double luas = 3.14*Sisi1*Sisi2;
  48.         editTextLuas.setText(luas + "");
  49.     }
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top