Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Tugas;
- public class Kalkulator {
- //deklarasi variabel sebagai private
- private int tambah, kurang, kali;
- private float bagi;
- //membuat method setter dan getter
- public void setKali(int angka1, int angka2){
- kali = angka1 * angka2;
- }
- public void setKurang(int angka1, int angka2){
- kurang = angka1 - angka2;
- }
- public void setTambah(int angka1, int angka2){
- tambah = angka1 + angka2;
- }
- public void setBagi(float angka1, float angka2){
- bagi = angka1 / angka2;
- }
- public int getKali(){
- return kali;
- }
- public int getKurang(){
- return kurang;
- }
- public int getTambah(){
- return tambah;
- }
- public float getBagi(){
- return bagi;
- }
- }
Add Comment
Please, Sign In to add comment