BlackBoY_

Kalkulator

Jul 7th, 2021 (edited)
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Tugas;
  2.  
  3. public class Kalkulator {
  4.     //deklarasi variabel sebagai private
  5.     private int tambah, kurang, kali;
  6.     private float bagi;
  7.    
  8.     //membuat method setter dan getter
  9.     public void setKali(int angka1, int angka2){
  10.         kali = angka1 * angka2;
  11.     }
  12.     public void setKurang(int angka1, int angka2){
  13.          kurang = angka1 - angka2;
  14.     }
  15.     public void setTambah(int angka1, int angka2){
  16.         tambah = angka1 + angka2;
  17.     }
  18.     public void setBagi(float angka1, float angka2){
  19.         bagi = angka1 / angka2;
  20.     }
  21.    
  22.     public int getKali(){
  23.         return kali;
  24.     }
  25.     public int getKurang(){
  26.         return kurang;
  27.     }
  28.     public int getTambah(){
  29.         return tambah;
  30.     }
  31.     public float getBagi(){
  32.         return bagi;
  33.     }
  34. }
  35.  
Add Comment
Please, Sign In to add comment