Advertisement
Guest User

Payroll System

a guest
Jan 28th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.79 KB | None | 0 0
  1. package payrollsystem3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PayrollSystem3 {
  6.  
  7.     static Scanner sc = new Scanner(System.in);
  8.     static String payrollheader = ("Payroll System");
  9.     static String design = ("=======================\n");
  10.  
  11.     public static void main(String[] args) {
  12.         System.out.println(design + payrollheader);
  13.         System.out.println("R=Regular");
  14.         System.out.println("C=Contractual");
  15.        boolean keepgoing=true;
  16.         while (keepgoing){
  17.         int regularhourswork = 40;
  18.         int regularrate = 40;
  19.         int overtimerate = 50;
  20.         double sss = 45.50;
  21.         int medicare = 50;
  22.         int pagibig = 50;
  23.         double tax = 0.08;
  24.         double salary = 0;
  25.         int hazzardtrigger = 55;
  26.         int hazzardpay = 300;
  27.         int cregrate = 30;
  28.         int chourswork = 40;
  29.         int otrate = 35;
  30.         double chazpay = 0.1;
  31.         System.out.println(design + "Select Employee type:");
  32.         String employeetype = sc.next();
  33.         if (employeetype.equalsIgnoreCase("") || employeetype.equalsIgnoreCase("R")) {
  34.             System.out.println(design + "Enter number of hours work:");
  35.             int numberofhourswork = sc.nextInt();
  36.             regularhourswork = regularrate * regularhourswork;
  37.             System.out.println(design + "Deduction:");
  38.             if (numberofhourswork >= 0 && numberofhourswork <= 40) {
  39.                 salary = numberofhourswork * regularrate;
  40.                 tax = salary * tax;
  41.                 salary = salary - tax - sss - medicare - pagibig;
  42.  
  43.             } else if (numberofhourswork <= hazzardtrigger) {
  44.                 overtimerate = (numberofhourswork - regularrate) * overtimerate;
  45.                 salary = regularhourswork + overtimerate;
  46.                 tax = salary * tax;
  47.                 salary = salary - tax - sss - medicare - pagibig;
  48.             } else if (numberofhourswork > hazzardtrigger) {
  49.                 overtimerate = (numberofhourswork - regularrate) * overtimerate;
  50.                 salary = regularhourswork + overtimerate + hazzardpay;
  51.                 tax = salary * tax;
  52.                 salary = salary - tax - sss - medicare - pagibig;
  53.             } else {
  54.                 System.out.println("Invalid Input");
  55.             }
  56.             System.out.println("Tax:" + tax);
  57.             System.out.println("SSS:" + sss);
  58.             System.out.println("Medicare:" + medicare);
  59.             System.out.println("Pag ibig:" + pagibig);
  60.             System.out.println(design + "Computed Salary:" + salary);
  61.         }
  62.         if (employeetype.equalsIgnoreCase("") || employeetype.equalsIgnoreCase("c")) {
  63.             System.out.println(design + "Enter number of hours work:");
  64.             int numberofhourswork = sc.nextInt();
  65.             chourswork = cregrate * chourswork;
  66.             System.out.println(design + "Deduction:");
  67.             if (numberofhourswork >= 0 && numberofhourswork <= 40) {
  68.                 salary = numberofhourswork * cregrate;
  69.  
  70.             } else if (numberofhourswork <= hazzardtrigger) {
  71.                 otrate = (numberofhourswork - 40) * otrate;
  72.                 salary = chourswork + otrate;
  73.  
  74.             } else if (numberofhourswork > hazzardtrigger) {
  75.                 otrate = (numberofhourswork - 40) * otrate;
  76.                 salary =chourswork + otrate;
  77.                 chazpay = salary * chazpay;
  78.                 salary = salary + chazpay;
  79.             } else {
  80.                 System.out.println("Invalid Input");
  81.             }
  82.              System.out.println(design + "Computed Salary:" + salary);
  83.         }
  84.          System.out.println("Do you want to transact another transaction?");
  85.          keepgoing=sc.next().toLowerCase().startsWith("y");
  86.     }
  87.          System.out.println("Goodbye and thank you for using our payroll system");
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement