[Tugas Kuliah] Program Laporan Gaji Pegawai Dengan JAVA

  • Posted by Virgiawan Listanto
  • at 8:03 AM -
  • 4 comments
Woke, hari ini adalah hari yang indah karena kita mendapatkan tugas lagi dan pastinya mumet2 lagi =))
Baik, Tugas kali ini adalah membuat Program Laporan Gaji Pegawai dengan JAVA. Dan tentunya sebelum mengerjakan tugas ini, Format soal sudah dibuat sedemikian rupa oleh pak dosen, sehingga kita dapat menikmati masa-masa Njepat bersama-sama =))

Oke dari pada mumet, langsung saja ke soal latihan!

Soal Latihan:
1. Buatlah Program Laporan Gaji Pegawai Dengan Ketentuan:


2. Input Data: Golongan, Kode Pegawai, Nama Pegawai, Absensi
3. Output Data: Kode, Nama, Gol, Absensi, Jabatan, Gaji Pokok, Transport/Hr, Absensi, Tunjangan Transport, Gaji Kotor, PPH, Gaji Bersih

Kriteria Dan Rumus:
- Tunjangan Transport = Transport/Hr * Absensi
- Gaji Kotor = Gaji Pokok + Tunjangan Transport
- PPH = Jika Gaji Kotor >=1.500.000 maka Gaji Kotor * 2% selain itu 0 (Tidak kena PPH)
- Gaji Bersih =Gaji Kotor – PPH

Dan Untuk Contoh Hasilnya akan tercipta seperti ini:


Untuk Algoritma SI dan Pseudocode serta Flowchart Program, Hampir sama dengan Tugas Sebelumnya. Maka dari itu, langsung saja kita coding programmnya :D

The Code:
Nama File: gajiPegawaiScanner.java
import java.util.Scanner;
import java.text.*;

class gajiPegawaiScanner {
 public static void main(String[] args) {
  try{
   Scanner masukan=new Scanner(System.in);
   NumberFormat formatnomor = new DecimalFormat("#,##,###");  
   
   // properties
   String kodepegawai        = "Kode Pegawai\t: ";
   String namapegawai        = "Nama Pegawai\t: ";
   String golongan           = "Golongan\t: ";
   String absensi            = "Absensi \t: ";
   String jabatan            = "Jabatan \t: ";
   String transport          = "Transport/hr\t: ";
   String gajipokok          = "Gaji Pokok\t: ";
   String tunjangantransport = "Tj. Transport\t: ";
   String gajikotor          = "Gaji Kotor\t: ";
   String pph                = "PPH (Pajak) \t: ";
   String gajibersih         = "Gaji Bersih\t: ";

   // Properties Pilihan
   String golput1 = "-> [1] Golongan 1 (Manager)";
   String golput2 = "-> [2] Golongan 2 (Supervisor)";
   String golput3 = "-> [3] Golongan 3 (Staff)";
   String golput4 = "-> [4] Golongan 4 (Assisten Staff)";

   // output pertama
   System.out.println("=============================================");
   System.out.println("Title\t: Program Laporan Gaji Pegawai");
   System.out.println("Coder\t: Virgiawan Listanto");
   System.out.println("Website\t: www.id-webmaster.com");
   System.out.println("============================================= \n");

   // Tampilkan Pilihan
   System.out.println(golput1);
   System.out.println(golput2);
   System.out.println(golput3);
   System.out.println(golput4+"\n");

   System.out.print("> Silahkan Masukan Nomor Golongan : ");

   int gol = masukan.nextInt();

   switch (gol){
    case 1:
     // properties -> golongan 1
     int transport1  = 100000;
     int gajipokok1  = 2000000;
     double potongan = 0.02; //2%
     String jbt1     = "Manager";

     System.out.println("\n===========================================");
     System.out.println("> Anda Memilih "+golput1);
     System.out.println("=========================================== \n");

     System.out.print("> "+kodepegawai);
     String kp1 = masukan.next();

     System.out.print("> "+namapegawai);
     String np1 = masukan.next();

     System.out.print("> "+absensi);
     int abs1 = masukan.nextInt();

     System.out.println("\n=============================");
     System.out.println("--- Cetak Laporan Pegawai ---");
     System.out.println("=============================\n");

     System.out.println("- "+kodepegawai+""+kp1);
     System.out.println("- "+namapegawai+""+np1);
     System.out.println("- "+golongan+""+gol);
     System.out.println("- "+absensi+""+abs1);
     System.out.println("- "+jabatan+""+jbt1);
     System.out.println("- "+transport+""+formatnomor.format(transport1)+"\n");
     
     System.out.println("- "+gajipokok+""+formatnomor.format(gajipokok1));
     
     // tunjangan transport (transport/hr * absensi)
     int tt1 = transport1*abs1;
     System.out.println("- "+tunjangantransport+""+formatnomor.format(tt1));

     System.out.println("---------------------------\n");
     
     // gaji kotor (tunjangan transport + gajipokok)
     int gk1 = gajipokok1+tt1;
     System.out.println("- "+gajikotor+""+formatnomor.format(gk1));

     // pph
     if(gk1 >= 1500000){
      double pphtotal = gk1*potongan;
      System.out.println("- "+pph+""+formatnomor.format(pphtotal));

      // gaji bersih
      double gbh1 = gk1-gk1*potongan;
            
      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh1)+"\n");
     }
     else{
      System.out.println("- "+pph+" 0 (tidak kena pph)");

      // gaji bersih
      int gbh1 = gk1-gk1*0;

      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh1)+"\n");
     }
    break;

    case 2:
     // properties -> golongan 2
     int transport2   = 75000;
     int gajipokok2   = 1500000;
     double potongan2 = 0.02; //2%
     String jbt2      = "Supervisor";

     System.out.println("\n=============================================");
     System.out.println("> Anda Memilih "+golput2);
     System.out.println("============================================= \n");

     System.out.print("> "+kodepegawai);
     String kp2 = masukan.next();

     System.out.print("> "+namapegawai);
     String np2 = masukan.next();

     System.out.print("> "+absensi);
     int abs2 = masukan.nextInt();

     System.out.println("\n=============================");
     System.out.println("--- Cetak Laporan Pegawai ---");
     System.out.println("=============================\n");

     System.out.println("- "+kodepegawai+""+kp2);
     System.out.println("- "+namapegawai+""+np2);
     System.out.println("- "+golongan+""+gol);
     System.out.println("- "+absensi+""+abs2);
     System.out.println("- "+jabatan+""+jbt2);
     System.out.println("- "+transport+""+formatnomor.format(transport2)+"\n");
     
     System.out.println("- "+gajipokok+""+formatnomor.format(gajipokok2));
     
     // tunjangan transport (transport/hr * absensi)
     int tt2 = transport2*abs2;
     System.out.println("- "+tunjangantransport+""+formatnomor.format(tt2));

     System.out.println("---------------------------\n");
     
     // gaji kotor (tunjangan transport + gajipokok)
     int gk2 = gajipokok2+tt2;
     System.out.println("- "+gajikotor+""+formatnomor.format(gk2));

     // pph
     if(gk2 >= 1500000){
      double pphtotal2 = gk2*potongan2;
      System.out.println("- "+pph+""+formatnomor.format(pphtotal2));

      // gaji bersih
      double gbh2 = gk2-gk2*potongan2;
            
      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh2)+"\n");
     }
     else{
      System.out.println("- "+pph+" 0 (tidak kena pph)");

      // gaji bersih
      int gbh2 = gk2-gk2*0;

      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh2)+"\n");
     }
    break;

    case 3:
     // Properties -> golongan 3
     int transport3   = 50000;
     int gajipokok3   = 1000000;
     double potongan3 = 0.02; //2%
     String jbt3      = "Staff";

     System.out.println("\n===========================================");
     System.out.println("> Anda Memilih "+golput3);
     System.out.println("=========================================== \n");

     System.out.print("> "+kodepegawai);
     String kp3 = masukan.next();

     System.out.print("> "+namapegawai);
     String np3 = masukan.next();

     System.out.print("> "+absensi);
     int abs3 = masukan.nextInt();

     System.out.println("\n=============================");
     System.out.println("--- Cetak Laporan Pegawai ---");
     System.out.println("=============================\n");

     System.out.println("- "+kodepegawai+""+kp3);
     System.out.println("- "+namapegawai+""+np3);
     System.out.println("- "+golongan+""+gol);
     System.out.println("- "+absensi+""+abs3);
     System.out.println("- "+jabatan+""+jbt3);
     System.out.println("- "+transport+""+formatnomor.format(transport3)+"\n");
     
     System.out.println("- "+gajipokok+""+formatnomor.format(gajipokok3));
     
     // tunjangan transport (transport/hr * absensi)
     int tt3 = transport3*abs3;
     System.out.println("- "+tunjangantransport+""+formatnomor.format(tt3));

     System.out.println("---------------------------\n");
     
     // gaji kotor (tunjangan transport + gajipokok)
     int gk3 = gajipokok3+tt3;
     System.out.println("- "+gajikotor+""+formatnomor.format(gk3));

     // pph
     if(gk3 >= 1500000){
      double pphtotal3 = gk3*potongan3;
      System.out.println("- "+pph+""+formatnomor.format(pphtotal3));

      // gaji bersih
      double gbh3 = gk3-gk3*potongan3;
            
      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh3)+"\n");
     }
     else{
      System.out.println("- "+pph+" 0 (tidak kena pph)");

      // gaji bersih
      int gbh3 = gk3-gk3*0;

      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh3)+"\n");
     }
    break;

    case 4:
     // Properties -> golongan 4
     int transport4   = 50000;
     int gajipokok4   = 750000;
     double potongan4 = 0.02; //2%
     String jbt4      = "Assisten Staff";

     System.out.println("\n===========================================");
     System.out.println("> Anda Memilih "+golput4);
     System.out.println("=========================================== \n");

     System.out.print("> "+kodepegawai);
     String kp4 = masukan.next();

     System.out.print("> "+namapegawai);
     String np4 = masukan.next();

     System.out.print("> "+absensi);
     int abs4 = masukan.nextInt();

     System.out.println("\n=============================");
     System.out.println("--- Cetak Laporan Pegawai ---");
     System.out.println("=============================\n");

     System.out.println("- "+kodepegawai+""+kp4);
     System.out.println("- "+namapegawai+""+np4);
     System.out.println("- "+golongan+""+gol);
     System.out.println("- "+absensi+""+abs4);
     System.out.println("- "+jabatan+""+jbt4);
     System.out.println("- "+transport+""+formatnomor.format(transport4)+"\n");
     
     System.out.println("- "+gajipokok+""+formatnomor.format(gajipokok4));
     
     // tunjangan transport (transport/hr * absensi)
     int tt4 = transport4*abs4;
     System.out.println("- "+tunjangantransport+""+formatnomor.format(tt4));

     System.out.println("---------------------------\n");
     
     // gaji kotor (tunjangan transport + gajipokok)
     int gk4 = gajipokok4+tt4;
     System.out.println("- "+gajikotor+""+formatnomor.format(gk4));

     // pph
     if(gk4 >= 1500000){
      double pphtotal4 = gk4*potongan4;
      System.out.println("- "+pph+""+formatnomor.format(pphtotal4));

      // gaji bersih
      double gbh4 = gk4-gk4*potongan4;
            
      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh4)+"\n");
     }
     else{
      System.out.println("- "+pph+" 0 (tidak kena pph)");

      // gaji bersih
      int gbh4 = gk4-gk4*0;

      System.out.println("---------------------------\n");
      System.out.println("- "+gajibersih+""+formatnomor.format(gbh4)+"\n");
     }
    break;

    default:
     System.out.println("Masukan Golongan 1, 2, 3, atau 4\n");
   }

  }
  catch (Exception e){
   System.out.println("System Error");
  }
 }
}

Oke sudah rampung, sekarang kita simak screen shoot nya :D

Oke, silahkan di comot source codenya gan =))

Share This Post

4 comments:

  1. manteb banget neh maskodok, ijin comot mas..... :)

    ReplyDelete
  2. wah, bermanfaat banget... ijin pelajarin sourcenya nh... Mampir di blog ane bang, Materi-it.com ... hehe salam Anak IT nh ... :p

    ReplyDelete
  3. Mantap bg,, Yang mau ngajari saya boleh kok, di email aja, salam IT, Saran mas Flowchart nya sekalian dong mas :D

    ReplyDelete