Skip to content
Snippets Groups Projects
Commit 2ccf3d1f authored by ShidehY's avatar ShidehY Committed by GitHub
Browse files

Add files via upload

parent 80b12142
No related branches found
No related tags found
No related merge requests found
File added
File added
E;011F42;Heidecker, Tim;President;120000
E;321FF0;Wareheim, Eric;CEO;112000
E;432890;Hart, David;Accountant;65000
E;F91AC1;Brule, Steve;Quality Control Specialist;34000
E;89FFAC;Quall, James;Programmer I;45000
T;5729FF;Dunn, Richard;Receptionist;12.50;34.25
T;B0CAF2;Hamburger, Neil;Janitor;10.20;28.00
S;FA0112;Skylar, Jan;Professional Assistant;8.45;40.00
S;F3CB01;Skylar, Wayne;Technical Writer;24.32;24
ID Name Type Title Gross Taxes Net
011F42 Heidecker, Tim Salary President $ 2307.69 $ 461.54 $ 1946.15
321FF0 Wareheim, Eric Salary CEO $ 2153.85 $ 430.77 $ 1823.08
432890 Hart, David Salary Accountant $ 1250.00 $ 250.00 $ 1100.00
F91AC1 Brule, Steve Salary Quality Control Specialist $ 653.85 $ 130.77 $ 623.08
89FFAC Quall, James Salary Programmer I $ 865.38 $ 173.08 $ 792.31
5729FF Dunn, Richard Temporary Receptionist $ 428.13 $ 0.00 $ 428.13
B0CAF2 Hamburger, Neil Temporary Janitor $ 285.60 $ 0.00 $ 285.60
FA0112 Skylar, Jan Staff Professional Assistant $ 338.00 $ 50.70 $ 287.30
F3CB01 Skylar, Wayne Staff Technical Writer $ 583.68 $ 87.55 $ 496.13
package org.cinco.payroll;
public class Employee {
}
\ No newline at end of file
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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment