Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PayrollPreparation {
- private File source;
- private Scanner input;
- private String payrollType;
- private int employeeID;
- private String employeeName;
- private int hoursWorked;
- private double payRate;
- private double straightPay;
- public void printEmployeeData() {
- System.out.println("Employee ID Name Hours Worked Pay Amount");
- try {
- source = new File("Payroll.txt");
- input = new Scanner(source);
- input.useDelimiter("[,n]");
- } catch (Exception e) {
- System.out.println(e);
- }
- while (input.hasNext()) {
- if (payrollType.equals("S")) {
- employeeID = input.nextInt();
- employeeName = input.next();
- hoursWorked = input.nextInt();
- payRate = input.nextDouble();
- payrollType = input.next();
- straightPay = (hoursWorked * payRate);
- System.out.println(" " + employeeID + " " + employeeName
- + " "
- + hoursWorked + " " + straightPay);
- input.nextLine();
- }
- }
- System.out.println("No More Salaried Employees.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement