Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tugas.akhir;
- import java.util.Scanner;
- public class TugasAkhir {
- public static String nama[];
- public static int[] golongan, gajiTotal, jamLembur, jumlahAnak;
- public static int[] gajiLembur = new int[9];
- public static int[] gapokGol = new int[3];
- public static int[] gajiAnak = new int[9];
- //fungsi inputan
- static void inputan() {
- Scanner input = new Scanner(System.in);
- System.out.print("Masukkan jumlah data : ");
- int data = input.nextInt();
- nama = new String[data];
- golongan = new int[data];
- jamLembur = new int[data];
- jumlahAnak = new int[data];
- gajiTotal = new int[data];
- for (int i = 0; i < nama.length; i++) {
- System.out.println("Memasukkan data karyawan ke " + (i + 1));
- Scanner in = new Scanner(System.in);
- System.out.print("Masukkan nama karyawan : ");
- nama[i] = in.nextLine();
- System.out.print("Masukkan golongan karyawan (0/1/2): ");
- golongan[i] = in.nextInt();
- System.out.print("Masukkan lama lembur karyawan (jam) : ");
- jamLembur[i] = in.nextInt();
- System.out.print("Masukkan jumlah anak : ");
- jumlahAnak[i] = in.nextInt();
- }
- System.out.println("");
- }
- //fungsi untuk menghapus data
- static void hapusData() {
- Scanner del = new Scanner(System.in);
- System.out.print("Masukkan Nama Karyawan Yang Ingin Dihapus : ");
- String dataNama = del.next();
- for (int j = 0; j < nama.length; j++) {
- if (nama[j].equalsIgnoreCase(dataNama)) {
- if (j == nama.length - 1) {
- nama[j] = "";
- golongan[j] = 0;
- jamLembur[j] = 0;
- System.out.println("=====DATA KARYAWAN BERHASIL DIHAPUS=====");
- break;
- } else {
- while (j == nama.length - 1) {
- nama[j] = nama[j + 1];
- nama[j + 1] = "";
- golongan[j] = golongan[j + 1];
- golongan[j + 1] = 0;
- jamLembur[j] = jamLembur[j + 1];
- jamLembur[j + 1] = 0;
- j++;
- break;
- }
- }
- }
- if (j == nama.length) {
- System.out.println("DATA TIDAK DITEMUKAN");
- }
- }
- }
- //fungsi untuk mencari data karyawan yang ingin dicari
- static void cariData() {
- Scanner masuk = new Scanner(System.in);
- System.out.print("Masukkan Nama Karyawan : ");
- String dataKaryawan = masuk.nextLine();
- for (int k = 0; k < nama.length; k++) {
- if (nama[k].equals(dataKaryawan)) {
- System.out.println("=====DATA KARYAWAN DITEMUKAN=====");
- tampilkanData(k);
- break;
- }
- if (k == nama.length) {
- System.out.println("=============================");
- System.out.println("DATA KARYAWAN TIDAK DITEMUKAN");
- System.out.println("=============================");
- }
- }
- }
- //fungsi untuk menampilkan data
- public static void tampilkanData(int x) {
- System.out.println("Nama Karyawan : " + nama[x] + "\nGolongan : " + golongan[x] + "\nLama Lembur : " + jamLembur[x]);
- System.out.println("===================================");
- }
- static void datakaryawan() {
- System.out.println("");
- System.out.println("==============RINCIAN DATA KARYAWAN===============");
- System.out.println("");
- System.out.println("No.| Nama Karyawan | Golongan | Lama Lembur");
- System.out.println("===========================================");
- for (int l = 0; l < nama.length; l++) {
- System.out.println((l + 1) + " " + (nama[l] + " | " + golongan[l] + " | " + jamLembur[l] + " |"));
- }
- }
- public static void gajiKaryawan() {
- gapokGol[0] = 3000000;
- gapokGol[1] = 2000000;
- gapokGol[2] = 1000000;
- gajiLembur[0] = 900000;
- gajiLembur[1] = 800000;
- gajiLembur[2] = 700000;
- gajiLembur[3] = 600000;
- gajiLembur[4] = 500000;
- gajiLembur[5] = 400000;
- gajiLembur[6] = 300000;
- gajiLembur[7] = 200000;
- gajiLembur[8] = 100000;
- gajiAnak[0] = 600000;
- gajiAnak[1] = 500000;
- gajiAnak[2] = 400000;
- for (int i = 0; i < nama.length; i++) {
- if (golongan[i] == 0) {
- if (jamLembur[i] < 5) {
- gajiTotal[i] = gapokGol[0] + gajiLembur[2] + gajiAnak[0];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[2]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[0]);
- } else if (jamLembur[i] >= 5 && 12 >= jamLembur[i]) {
- gajiTotal[i] = gapokGol[0] + gajiLembur[1] + gajiAnak[0];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[1]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[0]);
- } else if (jamLembur[i] < 13) {
- gajiTotal[i] = gapokGol[0] + gajiLembur[0] + gajiAnak[0];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[0]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[0]);
- }
- } else if (golongan[i] == 1) {
- if (jamLembur[i] < 5) {
- gajiTotal[i] = gapokGol[1] + gajiLembur[5] + gajiAnak[1];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[5]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[1]);
- } else if (jamLembur[i] >= 5 && 12 >= jamLembur[i]) {
- gajiTotal[i] = gapokGol[1] + gajiLembur[4] + gajiAnak[1];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[4]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[1]);
- } else if (jamLembur[i] < 13) {
- gajiTotal[i] = gapokGol[1] + gajiLembur[3] + gajiAnak[1];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[3]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[1]);
- }
- } else {
- if (jamLembur[i] < 5) {
- gajiTotal[i] = gapokGol[2] + gajiLembur[8] + gajiAnak[2];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[8]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[2]);
- } else if (jamLembur[i] >= 5 && 12 >= jamLembur[i]) {
- gajiTotal[i] = gapokGol[2] + gajiLembur[7] + gajiAnak[2];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[7]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[2]);
- } else if (jamLembur[i] < 13) {
- gajiTotal[i] = gapokGol[2] + gajiLembur[6] + gajiAnak[2];
- System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
- System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[6]);
- System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[2]);
- }
- }
- }
- }
- static void cetakLaporan() {
- for (int i = 0; i < nama.length; i++) {
- System.out.println("Nama : " + nama[i]);
- System.out.println("Golongan : " + golongan[i]);
- System.out.println("Lama lembur : " + jamLembur[i]+ " jam");
- System.out.println("Tunjangan : " + jumlahAnak[i] + " anak");
- System.out.println("Gaji Lembur : Rp " + gajiLembur[i]);
- System.out.println("Gaji Tunjangan : Rp "+gajiAnak[i]);
- System.out.println("Gaji Total : " + gajiTotal[i]);
- }
- }
- //main
- public static void main(String[] args) {
- int menu;
- System.out.println("=======================================");
- System.out.println("SELAMAT DATANG DI PT.TEKNIK INFORMATIKA");
- System.out.println("=======================================");
- do {
- System.out.println("");
- System.out.println("");
- System.out.println("-----MENU GAJI KARYAWAN PT.TEKNIK INFORMATIKA-----");
- System.out.println("1. Memasukkan Data Karyawan");
- System.out.println("2. Mencari Data Karyawan");
- System.out.println("3. Melihat Data Karyawan");
- System.out.println("4. Menghapus Data Karyawan");
- System.out.println("5. Melihat Gaji Karyawan");
- System.out.println("6. EXIT");
- System.out.println("");
- System.out.println("====================");
- System.out.println("");
- Scanner pilih = new Scanner(System.in);
- System.out.print("Masukkan Pilihan Menu (1/2/3/4/5) : ");
- menu = pilih.nextInt();
- System.out.println("");
- switch (menu) {
- case 1: {
- System.out.println("Menu - 1. Memasukkan Data Karyawan");
- inputan();
- }
- break;
- case 2: {
- System.out.println("Menu - 2. Mencari Data Karyawan");
- cariData();
- }
- break;
- case 3: {
- System.out.println("Menu - 3. Melihat Data Karyawan");
- datakaryawan();
- }
- break;
- case 4: {
- System.out.println("Menu - 4. Menghapus Data Karyawan");
- hapusData();
- }
- break;
- case 5: {
- System.out.println("Menu - 5. Melihat Gaji Karyawan");
- gajiKaryawan();
- }
- break;
- case 6: {
- System.out.println("Menu - 6. Cetak Laporan");
- cetakLaporan();
- }
- break;
- }
- } while (menu > 0 && menu < 7);
- System.out.println("TERIMA KASIH DAN SUKSES SELALU:D");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement