NOTE: As per the problem statement we did used the exact method descriptions. As the employee.txt is not given in text format so i used only 6 of the employee details manually put on the employee.txt, but you can run it on your system with full input file that you have.
P.S. ask for further clarification(if needed).
JAVA code for the above problem:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class AvaCam {
private static double overtimeRate = 0;
private static int count = 0;
private static double totalPayroll = 0;
private static double totalTaxes = 0;
private static double payrollCheckTotal = 0;
public static void userInstruct(){
JOptionPane.showMessageDialog(new JFrame(),"This program
does:\n"
+ "\nDisplay Payroll"
+ "\nWrite
Payroll","Welcome",JOptionPane.INFORMATION_MESSAGE);
}
private static double findSalary(double hours, double
rateOfPay, double overtimeRate){
double salary = (hours>40)?
(40)*rateOfPay : hours*rateOfPay; //base salary
salary += (hours>40)? (hours -
40)*overtimeRate : 0;//including overtime
return salary;
}
private static double findTaxes(double salary){
double taxes = 0;
if(salary <= 250.0) taxes =
0.18*salary;
else if(salary <= 550.0) taxes =
0.23 * salary;
else if(salary <= 1100.0) taxes
= 0.28*salary;
else taxes = 0.33 * salary;
return taxes;
}
private static double findNetIncome(double salary,
double taxes){
return salary - taxes;
}
public static void displayPayroll(double hours, double
salary, double taxes, double netIncome){
JOptionPane.showMessageDialog(new
JFrame(),"Hours: "+hours
+ "\nSalary: "+salary
+ "\nTaxed: "+taxes
+ "\nNet Come:
"+netIncome,"Payroll",JOptionPane.INFORMATION_MESSAGE);
}
public static void displayPayroll(double hours, double
salary, double taxes, double netIncome, double payRate, double
overtimeRate){
JOptionPane.showMessageDialog(new
JFrame(),"Hours: "+hours
+ "\nPay Rate: "+payRate
+ "\nOverTime Rate: "+overtimeRate
+ "\nSalary: "+salary
+ "\nTaxed: "+taxes
+ "\nNet Come:
"+netIncome,"Payroll",JOptionPane.INFORMATION_MESSAGE);
}
public static void writePayroll(double hours, double
salary, double taxes, double netIncome, PrintWriter
printWriter){
printWriter.write(" "+hours+"
"+salary+" "+taxes+"
"+netIncome+"\n");
}
public static void writePayroll(double hours, double
salary, double taxes, double netIncome, double payRate, double
overtimeRate, PrintWriter printWriter){
printWriter.write(" "+payRate+"
"+overtimeRate+" "+hours+" "+salary+" "+taxes+"
"+netIncome+"\n");
}
public static void main(String[] args) {
userInstruct();
String num =
JOptionPane.showInputDialog(new JFrame(),"Enter number of employees
to be processed: ");
try {
File myObj = new
File("C:\\Users\\user\\Desktop\\employees.txt");
PrintWriter printWriter = new
PrintWriter(new
File("C:\\Users\\user\\Desktop\\output_employees.txt"));
Scanner myReader = new
Scanner(myObj);
overtimeRate =
Double.parseDouble(myReader.nextLine().replaceAll(" ", ""));
while (myReader.hasNextLine())
{
String data =
myReader.nextLine();
String info[] =
data.split(" ");
String fname =
info[0];
String lname =
info[1];
double payRate =
Double.parseDouble(info[2].replaceAll(" ",""));
double hoursWorked
= Double.parseDouble(info[3].replaceAll(" ",""));
//
System.out.println(fname+" "+lname);
double salary =
findSalary(hoursWorked, payRate, overtimeRate);
double taxes =
findTaxes(salary);
double netIncome =
findNetIncome(salary, taxes);
displayPayroll(hoursWorked, salary, taxes, netIncome, payRate,
netIncome);
printWriter.write(fname+"\t"+lname);
writePayroll(hoursWorked, salary, taxes, netIncome, payRate,
netIncome, printWriter);
count++;
totalPayroll +=
salary;
totalTaxes +=
taxes;
payrollCheckTotal
+= netIncome;
}
printWriter.write("\n\nTotal
number of employees processed: "+count+"\nTotal Payroll:
"+totalPayroll
+"\nTotal Taxes:
"+totalTaxes
+ "\nTotal
Payroll Checks: "+payrollCheckTotal);
myReader.close();
printWriter.flush();
printWriter.close();
} catch (FileNotFoundException e)
{
System.out.println("An error
occurred.");
e.printStackTrace();
}
}
}
The demo employee.txt:
The output.txt file for above input file:
The dialog box screenshots:
1.
2.
3. For each employee this type of dialog box is popping up as follows:
The screenshot of above code snippets for better understanding:
employees.txt Instructions You will be using Eclipse for all assignments in this course. You can download...
By editing the code below to include composition, enums, toString; must do the following: Prompt the user to enter their birth date and hire date (see Fig. 8.7, 8.8 and 8.9 examples) in addition to the previous user input Create a new class that validates the dates that are input (can copy date class from the book) Incorporate composition into your class with these dates Use enums to identify the employee status as fulltime (40 or more hours worked for...
If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly pay) If the employee is not a supervisor and she worked 40 hours or less calculate her paycheck as her hourly wage * hours worked (regular pay) If the employee is not a supervisor and worked more than 40 hours calculate her paycheck as her (hourly wage * 40 ) + (1 ½ times here hourly wage * her hours worked over 40) (overtime...
Given attached you will find a file from Programming Challenge 5 of chapter 6 with required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: An empty string is given for the employee’s name. An invalid value is given to the employee’s ID number. If you implemented this field as a string, then an empty string could be invalid. If you implemented this field as a numeric variable, then a...
I would like help and there are three different classes in the coding.. 14.11 Prog11 Inheritance(PayrollOvertime) Create three files to submit: • Payroll class.java -Base class definition • PayrollOvertime.jave - Derived class definition • ClientClass.java - contains main() method Implement the two user define classes with the following specifications: Payroll class (the base class) (4 pts) • 5 data fields(protected) o String name - Initialized in default constructor to "John Doe" o int ID - Initialized in default constructor to...
Java Programming Reading from a Text File Write a Java program that will use an object of the Scanner class to read employee payroll data from a text file The Text file payroll.dat has the following: 100 Washington Marx Jung Darwin George 40 200 300 400 Kar Car Charles 50 22.532 15 30 The order of the data and its types stored in the file are as follows: Data EmployeelD Last name FirstName HoursWorked double HourlyRate Data Tvpe String String...
RUN THIS PROGRAM ON NETBEANS As a Software Developer, you have received a requirement from a Company to implement a prototype for its payroll system. You receive the following specifications: If an employee works more than its regular hours, it is considered overtime and it will be paid based on the employee’s experience. All employees are paid biweekly (80 hours) Employee taxes: 1% This company manages three categories of workers based on employee’s experience. Group 1 (Silver) o Pay rate:...
Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment. You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...
Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...
How would I do this problem? Write a C++ menu driven Payroll program. Must be user friendly. Menu 1. Check data file 2. Read Data file 3. Process payroll for one employee 4. Process payroll for all employees 5. Print out to a text or an HTML file 6. Exit You must use the following Payroll classes, structures, pointers, arrays, enum, vector, recursive, advance file I/O, STL, template, iterators and containers. The program to process an input file below to...
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...