Advertisement
AldiDwik

Tugas Akhir

Dec 16th, 2020
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.40 KB | None | 0 0
  1. package tugas.akhir;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TugasAkhir {
  6.  
  7. public static String nama[];
  8. public static int[] golongan, gajiTotal, jamLembur, jumlahAnak;
  9. public static int[] gajiLembur = new int[9];
  10. public static int[] gapokGol = new int[3];
  11. public static int[] gajiAnak = new int[9];
  12.  
  13. //fungsi inputan
  14. static void inputan() {
  15. Scanner input = new Scanner(System.in);
  16. System.out.print("Masukkan jumlah data : ");
  17. int data = input.nextInt();
  18. nama = new String[data];
  19. golongan = new int[data];
  20. jamLembur = new int[data];
  21. jumlahAnak = new int[data];
  22. gajiTotal = new int[data];
  23.  
  24. for (int i = 0; i < nama.length; i++) {
  25. System.out.println("Memasukkan data karyawan ke " + (i + 1));
  26. Scanner in = new Scanner(System.in);
  27. System.out.print("Masukkan nama karyawan : ");
  28. nama[i] = in.nextLine();
  29. System.out.print("Masukkan golongan karyawan (0/1/2): ");
  30. golongan[i] = in.nextInt();
  31. System.out.print("Masukkan lama lembur karyawan (jam) : ");
  32. jamLembur[i] = in.nextInt();
  33. System.out.print("Masukkan jumlah anak : ");
  34. jumlahAnak[i] = in.nextInt();
  35. }
  36. System.out.println("");
  37. }
  38.  
  39. //fungsi untuk menghapus data
  40. static void hapusData() {
  41. Scanner del = new Scanner(System.in);
  42. System.out.print("Masukkan Nama Karyawan Yang Ingin Dihapus : ");
  43. String dataNama = del.next();
  44.  
  45. for (int j = 0; j < nama.length; j++) {
  46. if (nama[j].equalsIgnoreCase(dataNama)) {
  47. if (j == nama.length - 1) {
  48. nama[j] = "";
  49. golongan[j] = 0;
  50. jamLembur[j] = 0;
  51. System.out.println("=====DATA KARYAWAN BERHASIL DIHAPUS=====");
  52. break;
  53. } else {
  54. while (j == nama.length - 1) {
  55. nama[j] = nama[j + 1];
  56. nama[j + 1] = "";
  57. golongan[j] = golongan[j + 1];
  58. golongan[j + 1] = 0;
  59. jamLembur[j] = jamLembur[j + 1];
  60. jamLembur[j + 1] = 0;
  61. j++;
  62. break;
  63. }
  64. }
  65. }
  66. if (j == nama.length) {
  67. System.out.println("DATA TIDAK DITEMUKAN");
  68. }
  69. }
  70. }
  71.  
  72. //fungsi untuk mencari data karyawan yang ingin dicari
  73. static void cariData() {
  74. Scanner masuk = new Scanner(System.in);
  75. System.out.print("Masukkan Nama Karyawan : ");
  76. String dataKaryawan = masuk.nextLine();
  77.  
  78. for (int k = 0; k < nama.length; k++) {
  79. if (nama[k].equals(dataKaryawan)) {
  80. System.out.println("=====DATA KARYAWAN DITEMUKAN=====");
  81. tampilkanData(k);
  82. break;
  83. }
  84. if (k == nama.length) {
  85. System.out.println("=============================");
  86. System.out.println("DATA KARYAWAN TIDAK DITEMUKAN");
  87. System.out.println("=============================");
  88. }
  89. }
  90. }
  91.  
  92. //fungsi untuk menampilkan data
  93. public static void tampilkanData(int x) {
  94.  
  95. System.out.println("Nama Karyawan : " + nama[x] + "\nGolongan : " + golongan[x] + "\nLama Lembur : " + jamLembur[x]);
  96. System.out.println("===================================");
  97. }
  98.  
  99. static void datakaryawan() {
  100. System.out.println("");
  101. System.out.println("==============RINCIAN DATA KARYAWAN===============");
  102. System.out.println("");
  103. System.out.println("No.| Nama Karyawan | Golongan | Lama Lembur");
  104. System.out.println("===========================================");
  105. for (int l = 0; l < nama.length; l++) {
  106. System.out.println((l + 1) + " " + (nama[l] + " | " + golongan[l] + " | " + jamLembur[l] + " |"));
  107.  
  108. }
  109. }
  110.  
  111. public static void gajiKaryawan() {
  112.  
  113. gapokGol[0] = 3000000;
  114. gapokGol[1] = 2000000;
  115. gapokGol[2] = 1000000;
  116.  
  117. gajiLembur[0] = 900000;
  118. gajiLembur[1] = 800000;
  119. gajiLembur[2] = 700000;
  120. gajiLembur[3] = 600000;
  121. gajiLembur[4] = 500000;
  122. gajiLembur[5] = 400000;
  123. gajiLembur[6] = 300000;
  124. gajiLembur[7] = 200000;
  125. gajiLembur[8] = 100000;
  126.  
  127.  
  128. gajiAnak[0] = 600000;
  129. gajiAnak[1] = 500000;
  130. gajiAnak[2] = 400000;
  131.  
  132. for (int i = 0; i < nama.length; i++) {
  133. if (golongan[i] == 0) {
  134. if (jamLembur[i] < 5) {
  135. gajiTotal[i] = gapokGol[0] + gajiLembur[2] + gajiAnak[0];
  136. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  137. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[2]);
  138. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[0]);
  139. } else if (jamLembur[i] >= 5 && 12 >= jamLembur[i]) {
  140. gajiTotal[i] = gapokGol[0] + gajiLembur[1] + gajiAnak[0];
  141. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  142. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[1]);
  143. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[0]);
  144. } else if (jamLembur[i] < 13) {
  145. gajiTotal[i] = gapokGol[0] + gajiLembur[0] + gajiAnak[0];
  146. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  147. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[0]);
  148. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[0]);
  149. }
  150. } else if (golongan[i] == 1) {
  151. if (jamLembur[i] < 5) {
  152. gajiTotal[i] = gapokGol[1] + gajiLembur[5] + gajiAnak[1];
  153. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  154. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[5]);
  155. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[1]);
  156. } else if (jamLembur[i] >= 5 && 12 >= jamLembur[i]) {
  157. gajiTotal[i] = gapokGol[1] + gajiLembur[4] + gajiAnak[1];
  158. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  159. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[4]);
  160. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[1]);
  161. } else if (jamLembur[i] < 13) {
  162. gajiTotal[i] = gapokGol[1] + gajiLembur[3] + gajiAnak[1];
  163. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  164. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[3]);
  165. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[1]);
  166. }
  167. } else {
  168. if (jamLembur[i] < 5) {
  169. gajiTotal[i] = gapokGol[2] + gajiLembur[8] + gajiAnak[2];
  170. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  171. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[8]);
  172. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[2]);
  173. } else if (jamLembur[i] >= 5 && 12 >= jamLembur[i]) {
  174. gajiTotal[i] = gapokGol[2] + gajiLembur[7] + gajiAnak[2];
  175. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  176. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[7]);
  177. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[2]);
  178. } else if (jamLembur[i] < 13) {
  179. gajiTotal[i] = gapokGol[2] + gajiLembur[6] + gajiAnak[2];
  180. System.out.println("Gaji Pokok " + nama[i] + " : Rp " + gajiTotal[i]);
  181. System.out.println("Gaji Lembur " + nama[i] + " : Rp " + gajiLembur[6]);
  182. System.out.println("Gaji Tunjangan " + nama[i] + " : Rp " + gajiAnak[2]);
  183. }
  184. }
  185. }
  186. }
  187.  
  188. static void cetakLaporan() {
  189. for (int i = 0; i < nama.length; i++) {
  190. System.out.println("Nama : " + nama[i]);
  191. System.out.println("Golongan : " + golongan[i]);
  192. System.out.println("Lama lembur : " + jamLembur[i]+ " jam");
  193. System.out.println("Tunjangan : " + jumlahAnak[i] + " anak");
  194. System.out.println("Gaji Lembur : Rp " + gajiLembur[i]);
  195. System.out.println("Gaji Tunjangan : Rp "+gajiAnak[i]);
  196. System.out.println("Gaji Total : " + gajiTotal[i]);
  197. }
  198. }
  199.  
  200. //main
  201. public static void main(String[] args) {
  202. int menu;
  203. System.out.println("=======================================");
  204. System.out.println("SELAMAT DATANG DI PT.TEKNIK INFORMATIKA");
  205. System.out.println("=======================================");
  206. do {
  207. System.out.println("");
  208. System.out.println("");
  209. System.out.println("-----MENU GAJI KARYAWAN PT.TEKNIK INFORMATIKA-----");
  210. System.out.println("1. Memasukkan Data Karyawan");
  211. System.out.println("2. Mencari Data Karyawan");
  212. System.out.println("3. Melihat Data Karyawan");
  213. System.out.println("4. Menghapus Data Karyawan");
  214. System.out.println("5. Melihat Gaji Karyawan");
  215. System.out.println("6. EXIT");
  216. System.out.println("");
  217. System.out.println("====================");
  218. System.out.println("");
  219. Scanner pilih = new Scanner(System.in);
  220. System.out.print("Masukkan Pilihan Menu (1/2/3/4/5) : ");
  221. menu = pilih.nextInt();
  222. System.out.println("");
  223. switch (menu) {
  224. case 1: {
  225. System.out.println("Menu - 1. Memasukkan Data Karyawan");
  226. inputan();
  227. }
  228. break;
  229. case 2: {
  230. System.out.println("Menu - 2. Mencari Data Karyawan");
  231. cariData();
  232. }
  233. break;
  234. case 3: {
  235. System.out.println("Menu - 3. Melihat Data Karyawan");
  236. datakaryawan();
  237. }
  238. break;
  239. case 4: {
  240. System.out.println("Menu - 4. Menghapus Data Karyawan");
  241. hapusData();
  242. }
  243. break;
  244. case 5: {
  245. System.out.println("Menu - 5. Melihat Gaji Karyawan");
  246. gajiKaryawan();
  247. }
  248. break;
  249. case 6: {
  250. System.out.println("Menu - 6. Cetak Laporan");
  251. cetakLaporan();
  252. }
  253. break;
  254. }
  255. } while (menu > 0 && menu < 7);
  256. System.out.println("TERIMA KASIH DAN SUKSES SELALU:D");
  257. }
  258. }
  259.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement