Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package payrollsystem1;
- import java.util.Scanner;
- public class Payrollsystem1 {
- static Scanner sc = new Scanner(System.in);
- double salary = 0, hazardPay;
- static String payrollheader = "Payroll System";
- static String divider = "============================\n";
- public static void main(String[] args) {
- System.out.println(divider + payrollheader);
- System.out.println("R = Regular");
- System.out.println("C = Contractual");
- boolean keepgoing = true;
- while (keepgoing) {
- double regularrate = 40;
- double overtimerate = 50;
- double hazzardpay = 300;
- double taxPercent = 0.08;
- double regularhour = 40;
- double cRegRate = 30;
- double cOtRate = 35;
- int hazzardtrigger = 55;
- double sss = 45.50;
- double pagibig = 50;
- double medicare = 50;
- double salary = 0, hazardPay;
- System.out.print(divider + "Select Employee Type: ");
- String empType = sc.next();
- if (empType.equalsIgnoreCase("") || empType.equalsIgnoreCase("R")) {
- System.out.print("Enter Working Hour: ");
- int numberofhourwork = sc.nextInt();
- regularhour = regularrate * regularhour;
- System.out.println("Deductions");
- if (numberofhourwork >= 0 && numberofhourwork <= 40) {
- salary = numberofhourwork * regularrate;
- taxPercent = salary * taxPercent;
- salary = salary - taxPercent - pagibig - sss - medicare;
- } else if (numberofhourwork <= hazzardtrigger) {
- overtimerate = (numberofhourwork - regularrate) * overtimerate;
- salary = regularhour + overtimerate;
- taxPercent = salary * taxPercent;
- salary = salary - taxPercent - pagibig - sss - medicare;
- } else if (numberofhourwork > 55) {
- overtimerate = (numberofhourwork - regularrate) * overtimerate;
- salary = regularhour + overtimerate + hazzardpay;
- taxPercent = salary * taxPercent;
- salary = (salary) - taxPercent - pagibig - sss - medicare;
- } else {
- System.out.println("Invalid Input");
- }
- System.out.println(" Tax: " + taxPercent);
- System.out.println(" SSS: " + sss);
- System.out.println(" PAG-IBIG: " + pagibig);
- System.out.println(" MEDICARE: " + medicare);
- System.out.println(divider + "Computed Salary: " + salary);
- }
- if (empType.equalsIgnoreCase("") || empType.equalsIgnoreCase("C")) {
- System.out.print("Enter Working Hour: ");
- int workHour = sc.nextInt();
- regularhour = cRegRate * regularhour;
- System.out.println("No deductions");
- if (workHour >= 0 && workHour <= 40) {
- salary = workHour * cRegRate;
- } else if (workHour <= 55) {
- overtimerate = (workHour - regularrate) * cOtRate;
- salary = regularhour + overtimerate;
- } else if (workHour > 55) {
- overtimerate = (workHour - regularrate) * cOtRate;
- salary = regularhour + overtimerate;
- hazardPay = salary * .10;
- salary = salary + hazardPay;
- } else {
- System.out.println("Invalid Input");
- }
- System.out.println(divider + "Salary: " + salary);
- }
- System.out.println("Do you want to process another transaction?");
- keepgoing = sc.next().toLowerCase().startsWith("y");
- }
- System.out.println("Goodbye and thank you for using our payroll system");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement