†`Li†o`† Admin
Posts : 80 Points : 168 Reputation : 9 Birthday : 1995-11-16 Join date : 2011-08-31 Age : 28 Location : Mayapa Calamba Laguna Job/hobbies : Playing Computer Games.
| Subject: Payroll Code Part 2 Mon Jul 02, 2012 4:03 pm | |
| - Quote :
- import java.io.*;
class Payroll{ static File emprec = new File ("e:employee.txt"); static BufferedReader In = new BufferedReader (new InputStreamReader(System.in)); private static String[] tmptime; private static double holidayrate; private static double[][] OTtimeInOut; private static double otrate;
public static void main (String[]jbi) throws Exception{ System.out.print("EMPLOYEE CODE: "); String empcode = In.readLine(); BufferedReader read = new BufferedReader(new FileReader(emprec)); String content; double salaryrate=0; while((content=read.readLine())!=null) { String[]info = content.split("."); String empName=info[1]; String empNum = info[0]; String empLevel = info[2];if (empNum.equals(empcode)) { System.out.println("*******************"); System.out.print("EMPLOYEE NAME: " + empName); System.out.print("\nEMPLOYEE CODE: " + empNum); System.out.print("\nSALARY LEVEL: Level" + empLevel); if(empLevel.equals("1")){System.out.println("\nSALARY RATE: Php 380.00/day"); salaryrate = 380; } else if (empLevel.equals("2")){System.out.println("\nSALARY RATE: Php 450.00/day"); salaryrate = 450; } else if (empLevel.equals("3")){System.out.println("\nSALARY RATE: Php 550.00/day"); salaryrate = 550; } System.out.println("*******************"); } }
String[]days = {"MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"}; Double timeInOut[][] = new Double[2][5]; double reghours = 0; double regincome = 0; double hourlyrate = 0,orate = 0, holiday=0; double othours = 0; double otIncome = 0; String ans; for(int x=0;x<=4;x++) { System.out.print("Enter the Time-In for"+days[x]+":"); String timeIn = In.readLine(); String[] Imptime = timeIn.split("."); String hour = tmptime[0]; String min = tmptime[1]; timeInOut[0][x] = Double.parseDouble(hour)+Double.parseDouble(min)/60;
System.out.print("Enter the Time-Out for"+days[x]+":"); String timeOut = In.readLine(); String[] ImptimeO = timeOut.split("."); String hourO = tmptime [0]; String minO = tmptime [1]; timeInOut[1][x] = Double.parseDouble(hourO)+Double.parseDouble(minO)/60; /////////////////////////// reghours += timeInOut[1][x]-timeInOut[0][x]-1; /////////////////////////// //HOLIDAY System.out.println("Is"+days[x]+"a holiday?"); ans=In.readLine(); if(ans.equals("yes")) { holidayrate=(salaryrate/8)*1.1; } else { hourlyrate=salaryrate/8; } regincome = reghours * (hourlyrate + holidayrate);
// ///////////////OVERTIME System.out.print("Enter the OverTime-In for"+days[x]+":"); String OTtimeIn=In.readLine(); String[]OTtmptime=OTtimeIn.split("."); String OThour = OTtmptime[0]; String OTmin = OTtmptime[1]; OTtimeInOut[0][x] = Double.parseDouble(OThour)+ Double.parseDouble(OTmin)/60; System.out.print("Enter the OverTime-Out for"+days[x]+":"); String OTtimeOut=In.readLine(); String[]OTtmptimeO=OTtimeOut.split("."); String OThourO = OTtmptimeO[0]; String OTminO = OTtmptimeO[1]; OTtimeInOut[1][x] = Double.parseDouble(OThour)+ Double.parseDouble(OTmin)/60;
othours += OTtimeInOut[1][x]-OTtimeInOut[0][x]; otrate = (salaryrate/8)*1.1; otIncome = othours*otrate;
}
System.out.print("\nENTER THE COVERAGE DATE OF THIS PAYROLL: "); String covdate = In.readLine(); System.out.println("*******************************"); System.out.println("DATE COVERED: "+covdate); System.out.println("TOTAL NUMBER of WORK HOURS: "+reghours); System.out.println("OVERTIME HOURS: "+othours); System.out.println("REGULAR INCOME: "+regincome); System.out.println("OVERTIME INCOME: "+otIncome); System.out.println("*************************");
}
}
- Quote :
- Notepad:
101,lito,2 102,dex,1
yan na po | |
|