Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package payrollsystem1;
  3.  
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class Payrollsystem1 {
  8.  
  9.     static Scanner sc = new Scanner(System.in);
  10.  
  11.  
  12.     double salary = 0, hazardPay;
  13.     static String payrollheader = "Payroll System";
  14.     static String divider = "============================\n";
  15.  
  16.     public static void main(String[] args) {
  17.         System.out.println(divider + payrollheader);
  18.  
  19.         System.out.println("R = Regular");
  20.         System.out.println("C  = Contractual");
  21.         boolean keepgoing = true;
  22.         while (keepgoing) {
  23.             double regularrate = 40;
  24.             double overtimerate = 50;
  25.             double hazzardpay = 300;
  26.             double taxPercent = 0.08;
  27.             double regularhour = 40;
  28.             double cRegRate = 30;
  29.             double cOtRate = 35;
  30.             int hazzardtrigger = 55;
  31.             double sss = 45.50;
  32.             double pagibig = 50;
  33.             double medicare = 50;
  34.  
  35.             double salary = 0, hazardPay;
  36.  
  37.             System.out.print(divider + "Select Employee Type: ");
  38.             String empType = sc.next();
  39.             if (empType.equalsIgnoreCase("") || empType.equalsIgnoreCase("R")) {
  40.                 System.out.print("Enter Working Hour: ");
  41.                 int numberofhourwork = sc.nextInt();
  42.                 regularhour = regularrate * regularhour;
  43.                 System.out.println("Deductions");
  44.  
  45.                 if (numberofhourwork >= 0 && numberofhourwork <= 40) {
  46.                     salary = numberofhourwork * regularrate;
  47.                     taxPercent = salary * taxPercent;
  48.                     salary = salary - taxPercent - pagibig - sss - medicare;
  49.                 } else if (numberofhourwork <= hazzardtrigger) {
  50.  
  51.                     overtimerate = (numberofhourwork - regularrate) * overtimerate;
  52.                     salary = regularhour + overtimerate;
  53.                     taxPercent = salary * taxPercent;
  54.                     salary = salary - taxPercent - pagibig - sss - medicare;
  55.                 } else if (numberofhourwork > 55) {
  56.                     overtimerate = (numberofhourwork - regularrate) * overtimerate;
  57.                     salary = regularhour + overtimerate + hazzardpay;
  58.                     taxPercent = salary * taxPercent;
  59.                     salary = (salary) - taxPercent - pagibig - sss - medicare;
  60.                 } else {
  61.                     System.out.println("Invalid Input");
  62.                 }
  63.  
  64.                 System.out.println("  Tax: " + taxPercent);
  65.                 System.out.println("  SSS: " + sss);
  66.                 System.out.println("  PAG-IBIG: " + pagibig);
  67.                 System.out.println("  MEDICARE: " + medicare);
  68.  
  69.                 System.out.println(divider + "Computed Salary: " + salary);
  70.             }
  71.             if (empType.equalsIgnoreCase("") || empType.equalsIgnoreCase("C")) {
  72.                 System.out.print("Enter Working Hour: ");
  73.                 int workHour = sc.nextInt();
  74.                 regularhour = cRegRate * regularhour;
  75.                 System.out.println("No deductions");
  76.                 if (workHour >= 0 && workHour <= 40) {
  77.                     salary = workHour * cRegRate;
  78.                 } else if (workHour <= 55) {
  79.                     overtimerate = (workHour - regularrate) * cOtRate;
  80.                     salary = regularhour + overtimerate;
  81.                 } else if (workHour > 55) {
  82.                     overtimerate = (workHour - regularrate) * cOtRate;
  83.                     salary = regularhour + overtimerate;
  84.                     hazardPay = salary * .10;
  85.                     salary = salary + hazardPay;
  86.                 } else {
  87.                     System.out.println("Invalid Input");
  88.                 }
  89.  
  90.                 System.out.println(divider + "Salary: " + salary);
  91.  
  92.             }
  93.             System.out.println("Do you want to process another transaction?");
  94.             keepgoing = sc.next().toLowerCase().startsWith("y");
  95.         }
  96.         System.out.println("Goodbye and thank you for using our payroll system");
  97.  
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement