Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Employee Data, I could use some help in where to go from here. Your program shou

ID: 3895002 • Letter: E

Question

Employee Data, I could use some help in where to go from here.

Your program should first use a dialog box to read from the user the number of employees to process. This number should be the same as the number of employees in the employees.txt file.

Your program should then read one employee at a time, compute their grossSalary(hoursWorked*payRate), taxes (taxRate*grossSalary), and netIncome (grossSalary-taxes). The programs should produce the payroll information to the output file named payroll.txt. The program should use the following payRate table to compute taxes:

package employeeTXT;

import java.io.*;

import java.util.*;

import javax.swing.*;

public class Assignment1 {

public static void main(String[] args) throws FileNotFoundException {

String fileName;

String firstName;

String lastName;

int hoursWorked, payRate, grossSalary, netIncome;

int countOfEmployees;

fileName = JOptionPane.showInputDialog("Enter the name of the file that holds employee information");

countOfEmployees = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of students in the file"));

Scanner inFile = new Scanner(new FileReader("\Users\sever2845\workspace\" + fileName + ".txt"));

PrintWriter outFile = new PrintWriter("\Users\sever2845\workspace\" + fileName + "-out.txt");

for (int i = 1; i <=countOfEmployees; i++) {

firstName = inFile.next();

lastName = inFile.next();

hoursWorked = inFile.nextInt();

payRate = inFile.nextInt();

JOptionPane.showMessageDialog(null, String.format("Processing &s %d ", firstName, lastName, hoursWorked, payRate), "Processing", JOptionPane.INFORMATION_MESSAGE);

}

}

}

Tax Bracket - Salary TaxRate <=$250.00 18% <=$550.00 23% <=$1100.00 28% otherwise 33%


Explanation / Answer

import java.io.*;

import java.util.*;

import javax.swing.*;

public class Assignment1 {

public static void main(String[] args) throws IOException {

String fileName;

String firstName;

String lastName;

int hoursWorked, payRate, grossSalary;

double netIncome;

int countOfEmployees;

fileName = JOptionPane.showInputDialog("Enter the name of the file that holds employee information");

countOfEmployees = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of students in the file"));

Scanner inFile = new Scanner(new FileReader("\Users\sever2845\workspace\" + fileName + ".txt"));

PrintWriter outFile = new PrintWriter("\Users\sever2845\workspace\" + fileName + "-out.txt");

for (int i = 1; i <=countOfEmployees; i++) {

firstName = inFile.next();

lastName = inFile.next();

hoursWorked = inFile.nextInt();

payRate = inFile.nextInt();

JOptionPane.showMessageDialog(null, String.format("Processing &s %d ", firstName, lastName, hoursWorked, payRate), "Processing", JOptionPane.INFORMATION_MESSAGE);

BufferedWriter bw = new BufferedWriter(new FileWriter("\\Users\\sever2845\\workspace\\payroll.txt"));

grossSalary = hoursWorked * payRate;

double taxes;

if(grossSalary < 250)

taxes = 0.18 * grossSalary;

else if(grossSalary < 550)

taxes = 0.23 * grossSalary;

else if(grossSalary < 1100)

taxes = 0.28 * grossSalary;

else

taxes = 0.33 * grossSalary;

netIncome = grossSalary - taxes;

bw.write("Employee " + String.valueOf(i) + " ");

bw.write("Gross Salary = " + String.valueOf(grossSalary)+ " ");

bw.write("Taxes = " + String.valueOf(taxes)+ " ");

bw.write("Net Income = " + String.valueOf(netIncome)+ " ");

bw.close();

}

}

}

**Comment for any further queries.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote