PEBEo
PEBEo
PEBEo
* Click /*
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license- * Click
default.txt to change this license nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-
* Click default.txt to change this license
nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java * Click
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
to edit this template to edit this template
*/ */
package uts; package uts;
import java.util.Scanner;
/**
/**
*
* * @author ACER
* @author ACER */
*/ public class Gaji {
public class Uts { private String nama;
private int lamaKerja;
private double gajiPokok;
/** private int lembur;
* @param args the command line arguments private double hitungLembur;
*/ protected double tunjangan;
public static void main(String[] args) { private double hitungGajiKotor;
private double gajiBersih;
Tunjangan t = new Tunjangan(); private double hitungPajak;
Scanner scan = new Scanner(System.in);
// Method nama
System.out.print("Masukkan Nama Pengguna: "); public void setNama(String nm) {
t.setNama(scan.nextLine()); this.nama = nm;
}
System.out.println("Lama Kerja"); public String getNama() {
System.out.println("1. Kurang dari 10 tahun"); return nama;
System.out.println("2. Lebih dari 10 tahun"); }
System.out.print("Masukkan pilihan anda: ");
// Method setter lamaKerja
int pilihan = scan.nextInt(); public void setLamaKerja(int LMK) {
this.lamaKerja = LMK;
switch (pilihan) { getGajiPokok();
case 1 -> t.setLamaKerja(10); }
case 2 -> t.setLamaKerja(11);
// Getter lama kerja
default -> { public int getLamaKerja() {
System.out.println("Pilihan tidak valid"); return lamaKerja;
return; }
}
}
// Setter lembur
System.out.print("Masukkan Jumlah Lembur (jam): public void setLembur(int lb) {
"); this.lembur = lb;
t.setLembur(scan.nextInt()); }
// Getter lembur
public int getLembur() {
System.out.println(""); return lembur;
System.out.println("Nama : " + }
t.getNama());
System.out.println("Gaji Pokok : " + // Method setter Gaji Pokok
public double getGajiPokok() {
t.getGajiPokok()); if (lamaKerja <= 10) {
System.out.println("Tunjangan : " + gajiPokok = 1000000;
t.getTunjangan()); } else {
System.out.println("Lembur : " + gajiPokok = 2000000;
t.getHitungLembur()); }
return gajiPokok;
System.out.println("Gaji Kotor : " + }
t.getGajiKotor());
System.out.println("Pajak : " + // hitung lembur
t.getHitungPajak()); public double getHitungLembur() {
System.out.println("Gaji Bersih : " + hitungLembur = lembur * 15000;
return hitungLembur;
t.getGajiBersih()); }
}
} // Hitung gaji kotor
public double getGajiKotor() {
hitungGajiKotor = gajiPokok + tunjangan +
getHitungLembur();
return hitungGajiKotor;
}