Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package payrollsystem3;
- import java.util.Scanner;
- public class PayrollSystem3 {
- static Scanner sc = new Scanner(System.in);
- static String payrollheader = ("Payroll System");
- static String design = ("=======================\n");
- public static void main(String[] args) {
- System.out.println(design + payrollheader);
- System.out.println("R=Regular");
- System.out.println("C=Contractual");
- boolean keepgoing=true;
- while (keepgoing){
- int regularhourswork = 40;
- int regularrate = 40;
- int overtimerate = 50;
- double sss = 45.50;
- int medicare = 50;
- int pagibig = 50;
- double tax = 0.08;
- double salary = 0;
- int hazzardtrigger = 55;
- int hazzardpay = 300;
- int cregrate = 30;
- int chourswork = 40;
- int otrate = 35;
- double chazpay = 0.1;
- System.out.println(design + "Select Employee type:");
- String employeetype = sc.next();
- if (employeetype.equalsIgnoreCase("") || employeetype.equalsIgnoreCase("R")) {
- System.out.println(design + "Enter number of hours work:");
- int numberofhourswork = sc.nextInt();
- regularhourswork = regularrate * regularhourswork;
- System.out.println(design + "Deduction:");
- if (numberofhourswork >= 0 && numberofhourswork <= 40) {
- salary = numberofhourswork * regularrate;
- tax = salary * tax;
- salary = salary - tax - sss - medicare - pagibig;
- } else if (numberofhourswork <= hazzardtrigger) {
- overtimerate = (numberofhourswork - regularrate) * overtimerate;
- salary = regularhourswork + overtimerate;
- tax = salary * tax;
- salary = salary - tax - sss - medicare - pagibig;
- } else if (numberofhourswork > hazzardtrigger) {
- overtimerate = (numberofhourswork - regularrate) * overtimerate;
- salary = regularhourswork + overtimerate + hazzardpay;
- tax = salary * tax;
- salary = salary - tax - sss - medicare - pagibig;
- } else {
- System.out.println("Invalid Input");
- }
- System.out.println("Tax:" + tax);
- System.out.println("SSS:" + sss);
- System.out.println("Medicare:" + medicare);
- System.out.println("Pag ibig:" + pagibig);
- System.out.println(design + "Computed Salary:" + salary);
- }
- if (employeetype.equalsIgnoreCase("") || employeetype.equalsIgnoreCase("c")) {
- System.out.println(design + "Enter number of hours work:");
- int numberofhourswork = sc.nextInt();
- chourswork = cregrate * chourswork;
- System.out.println(design + "Deduction:");
- if (numberofhourswork >= 0 && numberofhourswork <= 40) {
- salary = numberofhourswork * cregrate;
- } else if (numberofhourswork <= hazzardtrigger) {
- otrate = (numberofhourswork - 40) * otrate;
- salary = chourswork + otrate;
- } else if (numberofhourswork > hazzardtrigger) {
- otrate = (numberofhourswork - 40) * otrate;
- salary =chourswork + otrate;
- chazpay = salary * chazpay;
- salary = salary + chazpay;
- } else {
- System.out.println("Invalid Input");
- }
- System.out.println(design + "Computed Salary:" + salary);
- }
- System.out.println("Do you want to transact 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