Advertisement
AldiDwik

Tugas Akhir

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