diff --git a/bin/org/cinco/payroll/Employee.class b/bin/org/cinco/payroll/Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..5c6ae6480c932a1bff2fbee5efc8826a9d1ccc32 Binary files /dev/null and b/bin/org/cinco/payroll/Employee.class differ diff --git a/bin/org/cinco/payroll/PayrollReport.class b/bin/org/cinco/payroll/PayrollReport.class new file mode 100644 index 0000000000000000000000000000000000000000..c3a4f97ce1d715800bed592f8f40f81bf5914154 Binary files /dev/null and b/bin/org/cinco/payroll/PayrollReport.class differ diff --git a/src/org/cinco/payroll/Employee.java b/src/org/cinco/payroll/Employee.java index e090f8158ac28703adf12c3749732ad7316ed2ac..ad241b5c86263630ed2d9efd184b99463984d4a7 100755 --- a/src/org/cinco/payroll/Employee.java +++ b/src/org/cinco/payroll/Employee.java @@ -2,4 +2,4 @@ package org.cinco.payroll; public class Employee { -} \ No newline at end of file +} diff --git a/src/org/cinco/payroll/PayrollReport.java b/src/org/cinco/payroll/PayrollReport.java new file mode 100644 index 0000000000000000000000000000000000000000..415ec761b56db62f3ddd9311ee51761f6e703e68 --- /dev/null +++ b/src/org/cinco/payroll/PayrollReport.java @@ -0,0 +1,70 @@ +package org.cinco.payroll; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class PayrollReport { + + public static List<Employee> parseDataFile() { + List<Employee> result = new ArrayList<Employee>(); + try { + File f = new File("data/employee.dat"); + Scanner s = new Scanner(f); + while(s.hasNext()) { + String line = s.nextLine(); + if(!line.trim().isEmpty()) { + Employee e = null; + String tokens[] = line.split(";"); + String id = tokens[1]; + String nameTokens[] = tokens[2].split(","); + String lastName = nameTokens[0]; + String firstName = nameTokens[1]; + String title = tokens[3]; + double annualSalary = 0.0, hourlyPayRate = 0.0, hoursWorked = 0.0; + if(tokens.length == 6) { + hourlyPayRate = Double.parseDouble(tokens[4]); + hoursWorked = Double.parseDouble(tokens[5]); + } else if(tokens.length == 5) { + annualSalary = Double.parseDouble(tokens[4]); + } + + if(tokens[0].equals("E")) { + e = new Employee(); //TODO: modify this + } else if(tokens[0].equals("S")) { + e = new Employee(); //TODO: modify this + } else if(tokens[0].equals("T")) { + e = new Employee(); //TODO: modify this + } + + result.add(e); + } + } + } catch(Exception e) { + e.printStackTrace(); + } + return result; + } + + public static void main(String args[]) { + + //get the employees from the data file + List<Employee> payroll = parseDataFile(); + + StringBuilder sb = new StringBuilder(); + + sb.append(String.format("%-8s %-20s %-10s %-30s %9s %9s %9s\n", + "ID", "Name", "Type", "Title", "Gross", "Taxes", "Net")); + + //for each employee + for(Employee e : payroll) { + //format their information + sb.append(String.format("%-8s %-20s %-10s %-30s $%8.2f $%8.2f $%8.2f\n", + "TODO", "TODO", "TODO", "TODO", 0.0, 0.0, 0.0)); //TODO: replace these + } + + System.out.println(sb); + } + +}