Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class example {
- static Scanner sc= new Scanner(System.in);
- static int empnum , newempnum;
- static String empname, newempname;
- static int EDR;
- static int NHWM;
- static int NHA;
- static int SPM , Base;
- static double totaldeduction;
- static double additional;
- static double finalsalary;
- static double baseSal,basetax;
- static int totaltime;
- static int sss=550;
- static int PagIbig=500;
- static int Sales=0;
- static int CivStat;
- static int search;
- static double tax=0;
- static double Commissions;
- public static void main(String[] args) {
- char choice;
- do {
- System.out.println("\n====PAYROLL SYSTEM====\n");
- System.out.println("\tMenu:\t");
- System.out.println("\t[A]ADD\t");
- System.out.println("\t[B]UPDATE\t");
- System.out.println("\t[C]SEARCH\t");
- System.out.println("\t[D]DISPLAY ALL\t");
- System.out.println("\t[E]EXIT\t");
- System.out.println("\nPlease Enter Your Choice:");
- choice= sc.next().charAt(0);
- sc.nextLine();
- switch (choice) {
- case 'A':
- case 'a':
- System.out.println("Please Enter Employee's Name:");
- empname = sc.nextLine();
- System.out.println("Please Enter Employee Number:");
- empnum= sc.nextInt();
- System.out.println("Please Enter Hourly Rate: ");
- EDR=sc.nextInt();
- System.out.println("Please Enter Number Of Hours Work per Month: ");
- NHWM=sc.nextInt();
- System.out.println("Please Enter Number Of Hours Absent: ");
- NHA=sc.nextInt();
- System.out.println("Please Enter Civil Status:");
- System.out.println("[1]Married with children");
- System.out.println("[2]Married without children");
- System.out.println("[3]Single parent");
- System.out.println("[4]Single");
- CivStat=sc.nextInt();
- if(CivStat<=1)
- tax=0.05;
- else if(CivStat<=2)
- tax=0.10;
- else if(CivStat<=3)
- tax=0.05;
- else if(CivStat<=4)
- tax=0.15;
- else{
- System.out.println("Invalid Input");}
- System.out.println("Please Enter Sales per Month: ");
- SPM=sc.nextInt();
- if(SPM>=40000)
- Commissions=0.1;
- else if(SPM>=30000)
- Commissions=0.05;
- else if(SPM>=20000)
- Commissions=0.04;
- else if(SPM>=10000)
- Commissions=0.03;
- else
- Commissions=0;
- totaltime=NHWM-NHA;
- Base=EDR*totaltime;
- basetax = Base * tax;
- baseSal=Base - basetax;
- totaldeduction= basetax + sss + PagIbig;
- additional=Commissions*SPM;
- finalsalary = baseSal + additional - sss - PagIbig;
- break;
- case 'B':
- case 'b':
- {
- System.out.println("Please Enter Employee's Name:");
- newempname = sc.nextLine();
- empname = newempname;
- System.out.println("Please Enter Employee Number:");
- newempnum= sc.nextInt();
- if (newempnum == empnum){
- System.out.println("The number already taken ");
- System.out.println("---Input Unique number :");
- newempnum= sc.nextInt();
- }
- empnum = newempnum;
- sc.nextLine();
- System.out.println("Please Enter Hourly Rate: ");
- EDR=sc.nextInt();
- System.out.println("Please Enter Number Of Hours Work per Month: ");
- NHWM=sc.nextInt();
- System.out.println("Please Enter Number Of Hours Absent: ");
- NHA=sc.nextInt();
- System.out.println("Please Enter Civil Status:\n");
- System.out.println("[1]Married with children");
- System.out.println("[2]Married without children");
- System.out.println("[3]Single parent");
- System.out.println("[4]Single");
- CivStat=sc.nextInt();
- if(CivStat<=1)
- tax=0.05;
- else if(CivStat<=2)
- tax=0.10;
- else if(CivStat<=3)
- tax=0.05;
- else if(CivStat<=4)
- tax=0.15;
- else{
- System.out.println("Invalid Input");}
- System.out.println("Please Enter Sales per Month: ");
- SPM=sc.nextInt();
- if(SPM>=40000)
- Commissions=0.1;
- else if(SPM>=30000)
- Commissions=0.05;
- else if(SPM>=20000)
- Commissions=0.04;
- else if(SPM>=10000)
- Commissions=0.03;
- else
- Commissions=0;
- totaltime=NHWM-NHA;
- Base=EDR*totaltime;
- baseSal=Base - basetax;
- totaldeduction= basetax + sss + PagIbig;
- additional=Commissions*SPM;
- finalsalary = baseSal + additional - sss - PagIbig;
- break;
- }
- case 'C':
- case 'c':
- {
- System.out.println("You are searching for:");
- System.out.println("[1]Employee Number");
- System.out.println("[2]Employee's Name");
- search= sc.nextInt();
- if (search==1)
- System.out.println("Employee Number is "+empnum +".");
- else if (search==2)
- System.out.println("The Employee's Name is "+empname+ ".");
- else
- System.out.println("Oops!Nothing Found.");
- break;
- }
- case 'D':
- case 'd':
- {
- System.out.println("Employee Number: "+empnum);
- System.out.println("Employee's Name: "+empname);
- System.out.println("Employee's Daily Rate is: "+EDR);
- System.out.println("Number of Hours Work per Month: "+NHWM);
- System.out.println("Number of Hours Absent: "+NHA);
- System.out.println("Initialpay: "+Base);
- System.out.println("base salary: "+baseSal);
- System.out.println("Sales per Month: "+SPM);
- System.out.println("Total Deduction: "+totaldeduction);
- System.out.println("Final Salary: "+finalsalary);
- }
- }
- }
- while
- (choice!='E');
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment