grhey

PayrollSystem

Jul 6th, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.01 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class example {
  5.  
  6.  
  7.  
  8.  
  9. static Scanner sc= new Scanner(System.in);
  10. static int empnum , newempnum;
  11. static String empname, newempname;
  12. static int EDR;
  13. static int NHWM;
  14. static int NHA;
  15. static int SPM , Base;
  16. static double totaldeduction;
  17. static double additional;
  18. static double finalsalary;
  19. static double baseSal,basetax;
  20. static int totaltime;
  21. static int sss=550;
  22. static int PagIbig=500;
  23. static int Sales=0;
  24. static int CivStat;
  25. static int search;
  26. static double tax=0;
  27. static double Commissions;
  28.  
  29. public static void main(String[] args) {
  30.  
  31.  
  32.  
  33.  
  34.  
  35. char choice;
  36. do {
  37. System.out.println("\n====PAYROLL SYSTEM====\n");
  38. System.out.println("\tMenu:\t");
  39. System.out.println("\t[A]ADD\t");
  40. System.out.println("\t[B]UPDATE\t");
  41. System.out.println("\t[C]SEARCH\t");
  42. System.out.println("\t[D]DISPLAY ALL\t");
  43. System.out.println("\t[E]EXIT\t");
  44.  
  45. System.out.println("\nPlease Enter Your Choice:");
  46. choice= sc.next().charAt(0);
  47. sc.nextLine();
  48.  
  49.  
  50.  
  51. switch (choice) {
  52.  
  53. case 'A':
  54. case 'a':
  55. System.out.println("Please Enter Employee's Name:");
  56. empname = sc.nextLine();
  57. System.out.println("Please Enter Employee Number:");
  58. empnum= sc.nextInt();
  59. System.out.println("Please Enter Hourly Rate: ");
  60. EDR=sc.nextInt();
  61. System.out.println("Please Enter Number Of Hours Work per Month: ");
  62. NHWM=sc.nextInt();
  63. System.out.println("Please Enter Number Of Hours Absent: ");
  64. NHA=sc.nextInt();
  65. System.out.println("Please Enter Civil Status:");
  66. System.out.println("[1]Married with children");
  67. System.out.println("[2]Married without children");
  68. System.out.println("[3]Single parent");
  69. System.out.println("[4]Single");
  70. CivStat=sc.nextInt();
  71.  
  72.  
  73. if(CivStat<=1)
  74. tax=0.05;
  75. else if(CivStat<=2)
  76. tax=0.10;
  77. else if(CivStat<=3)
  78. tax=0.05;
  79. else if(CivStat<=4)
  80. tax=0.15;
  81. else{
  82. System.out.println("Invalid Input");}
  83.  
  84. System.out.println("Please Enter Sales per Month: ");
  85. SPM=sc.nextInt();
  86.  
  87. if(SPM>=40000)
  88. Commissions=0.1;
  89. else if(SPM>=30000)
  90. Commissions=0.05;
  91. else if(SPM>=20000)
  92. Commissions=0.04;
  93. else if(SPM>=10000)
  94. Commissions=0.03;
  95. else
  96. Commissions=0;
  97.  
  98. totaltime=NHWM-NHA;
  99. Base=EDR*totaltime;
  100. basetax = Base * tax;
  101. baseSal=Base - basetax;
  102. totaldeduction= basetax + sss + PagIbig;
  103. additional=Commissions*SPM;
  104. finalsalary = baseSal + additional - sss - PagIbig;
  105.  
  106.  
  107. break;
  108.  
  109. case 'B':
  110. case 'b':
  111. {
  112.  
  113. System.out.println("Please Enter Employee's Name:");
  114. newempname = sc.nextLine();
  115. empname = newempname;
  116.  
  117. System.out.println("Please Enter Employee Number:");
  118. newempnum= sc.nextInt();
  119.  
  120. if (newempnum == empnum){
  121. System.out.println("The number already taken ");
  122. System.out.println("---Input Unique number :");
  123. newempnum= sc.nextInt();
  124. }
  125. empnum = newempnum;
  126.  
  127. sc.nextLine();
  128. System.out.println("Please Enter Hourly Rate: ");
  129. EDR=sc.nextInt();
  130. System.out.println("Please Enter Number Of Hours Work per Month: ");
  131. NHWM=sc.nextInt();
  132. System.out.println("Please Enter Number Of Hours Absent: ");
  133. NHA=sc.nextInt();
  134. System.out.println("Please Enter Civil Status:\n");
  135. System.out.println("[1]Married with children");
  136. System.out.println("[2]Married without children");
  137. System.out.println("[3]Single parent");
  138. System.out.println("[4]Single");
  139. CivStat=sc.nextInt();
  140.  
  141. if(CivStat<=1)
  142. tax=0.05;
  143. else if(CivStat<=2)
  144. tax=0.10;
  145. else if(CivStat<=3)
  146. tax=0.05;
  147. else if(CivStat<=4)
  148. tax=0.15;
  149. else{
  150. System.out.println("Invalid Input");}
  151.  
  152. System.out.println("Please Enter Sales per Month: ");
  153. SPM=sc.nextInt();
  154.  
  155. if(SPM>=40000)
  156. Commissions=0.1;
  157. else if(SPM>=30000)
  158. Commissions=0.05;
  159. else if(SPM>=20000)
  160. Commissions=0.04;
  161. else if(SPM>=10000)
  162. Commissions=0.03;
  163. else
  164. Commissions=0;
  165.  
  166. totaltime=NHWM-NHA;
  167. Base=EDR*totaltime;
  168. baseSal=Base - basetax;
  169. totaldeduction= basetax + sss + PagIbig;
  170. additional=Commissions*SPM;
  171. finalsalary = baseSal + additional - sss - PagIbig;
  172. break;
  173. }
  174.  
  175. case 'C':
  176. case 'c':
  177. {
  178. System.out.println("You are searching for:");
  179. System.out.println("[1]Employee Number");
  180. System.out.println("[2]Employee's Name");
  181. search= sc.nextInt();
  182.  
  183. if (search==1)
  184. System.out.println("Employee Number is "+empnum +".");
  185. else if (search==2)
  186. System.out.println("The Employee's Name is "+empname+ ".");
  187. else
  188. System.out.println("Oops!Nothing Found.");
  189. break;
  190. }
  191. case 'D':
  192. case 'd':
  193. {
  194. System.out.println("Employee Number: "+empnum);
  195. System.out.println("Employee's Name: "+empname);
  196. System.out.println("Employee's Daily Rate is: "+EDR);
  197. System.out.println("Number of Hours Work per Month: "+NHWM);
  198. System.out.println("Number of Hours Absent: "+NHA);
  199. System.out.println("Initialpay: "+Base);
  200. System.out.println("base salary: "+baseSal);
  201. System.out.println("Sales per Month: "+SPM);
  202. System.out.println("Total Deduction: "+totaldeduction);
  203. System.out.println("Final Salary: "+finalsalary);
  204. }
  205. }
  206. }
  207.  
  208. while
  209. (choice!='E');
  210. System.exit(0);
  211. }
  212.  
  213.  
  214.  
  215.  
  216.  
  217. }
  218.  
  219.  
Advertisement
Add Comment
Please, Sign In to add comment