Advertisement
AldiDwik

Tugas Akhir

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