Question

In: Computer Science

You are to modify your payroll program from the last assignment to take the new copy...

You are to modify your payroll program from the last assignment to take the new copy of the payroll file called DeweyCheatemAndHow.txt which has the fields separated by a comma to use as input to your program and produce a file that lists all the salaried employee and their gross pay, then each hourly employee and their gross pay and finally each piece rate employee and their gross pay .

You are to process all the entries provided in the file and produce output that looks like this:

Dewey, Cheatem and How Law Firm

Payroll Repor

t Salaried Employees

First Name Last Name SSN Gross Pay $XXX.

First Name Last Name SSN Gross Pay $XXX.

First Name Last Name SSN Gross Pay $XXX.

Hourly Employees

First Name Last Name SSN Gross Pay $XXX.

First Name Last Name SSN Gross Pay $XXX.

Piece Rate Employees

First Name Last Name SSN Gross Pay $XXX.

First Name Last Name SSN Gross Pay $XXX.

In order to be able to group the employee types for the output you will need to use an array of employee and its size should be 30. Please note there will not be 30 entries in the DeweyCheatemAndHow.txt.

The input file has this :

s,028-13-3948,Andrew,Smith,1313,Mockingbird,Lane,513-556-7000,500.75s,028-24-9971,Andrew,Whaley,1776,Liberty,Ave,513-556-7001,675h,112-45-7867,Saif,Altarouti,3427,Smith,Rd,513-556-7002,20,40s,123-45-6789,Nicholas,Alonso,920,Ohio,Ave,513-556-7003,900s,123-94-3938,Abigail,Smith,1600,Penn,St,513-556-7004,1200h,123-97-4556,Matthew,Stewart,2925,Campus,Green,513-556-7005,16.5,40s,142-78-2367,Syeda,Mullen,345,Ludlow,Ave,513-556-7006,763p,143-49-0923,Arianna,Rhine,768,Stratford,Dr,513-556-7007,7.5,1000p,193-93-1283,Emmalese,Nuerge,132,Greyfox,Rd,513-556-7008,8.5,1010p,211-54-823,Joshua,Ayers,671,Buckwheat,Rd,513-556-7009,5.5,500h,258-29-9102,Nicholas,Roth,734,Student,Dr,513-556-7010,25,35

Language is Java

Solutions

Expert Solution

Here i am giving the answer. Hope it helps. please upvote. it helps me a lot.

//Employee class

public class Employee {
   private String Firstname;
   private String Lastname;
   private String Address;
   private String Phone;
   private String SSN;
  
//CONSTRUCTORS
  
   public Employee() {
   // TODO Auto-generated constructor stub
}


public Employee(String firstname, String lastname, String address, String phone, String sSN) {
       super();
       Firstname = firstname;
       Lastname = lastname;
       Address = address;
       Phone = phone;
       SSN = sSN;
}

//SETTERS FOR FIRSTNAME, LASTNAME, SSN
public void setFirstname(String firstname) {
   Firstname = firstname;
}


public void setLastname(String lastname) {
   Lastname = lastname;
}
  
public void setSSN(String sSN) {
   SSN = sSN;
}

//GETTERS FOR FIRSTNAME, LASTNAME, SSN, ADDRESS, PHONE
public String getFirstname() {
   return Firstname;
}

public String getLastname() {
   return Lastname;
}

public String getAddress() {
   return Address;
}

public String getPhone() {
   return Phone;
}


public String getSSN() {
   return SSN;
}

//TOSTRING METHOD

@Override
public String toString() {
   return "Employee [Firstname=" + Firstname + ", Lastname=" + Lastname + ", Address=" + Address + ", Phone=" + Phone + ", SSN=" + SSN + "]";
}

//EQUALS METHOD
@Override
public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       Employee other = (Employee) obj;
       if (Address == null) {
           if (other.Address != null)
               return false;
       } else if (!Address.equals(other.Address))
           return false;
       if (Firstname == null) {
           if (other.Firstname != null)
               return false;
       } else if (!Firstname.equals(other.Firstname))
           return false;
       if (Lastname == null) {
           if (other.Lastname != null)
               return false;
       } else if (!Lastname.equals(other.Lastname))
           return false;
       if (Phone == null) {
           if (other.Phone != null)
               return false;
       } else if (!Phone.equals(other.Phone))
           return false;
       if (SSN == null) {
           if (other.SSN != null)
               return false;
       } else if (!SSN.equals(other.SSN))
           return false;
       return true;
}


}

//SALARIED CLASS

public class Salaried extends Employee {
   private double Salary;
  
  
//CONSTRUCTORS
  
   public Salaried() {
   // TODO Auto-generated constructor stub
}


public Salaried( double salary ) {
       super();
       Salary = salary;
  
}

//SET METHOD FOR SALARY
public void setSalary(double salary) {
   Salary = salary;
}

//GET METHOD FOR SALARY
public double getSalary() {
   return Salary;
}

//TOSTRING METHOD

@Override
public String toString() {
   return "Salary=" + Salary ;
}

}

//HOURLY CLASS

public class Hourly extends Employee {
   private double PayRate;
   private double HoursWorked;
  
  
//CONSTRUCTORS
  
   public Hourly() {
   // TODO Auto-generated constructor stub
}


public Hourly(double payRate, double hoursWorked) {
       super();
       PayRate = payRate;
HoursWorked = hoursWorked;

}

//SETTERS FOR Payrate, HoursWorked
public void setPayRate(double payRate) {
   PayRate = payRate;
}


public void setHoursWorked(double hoursWorked) {
HoursWorked = hoursWorked;
}
  

//GETTERS FOR hoursWorked, Payrate
public double getPayRate() {
   return PayRate;
}

public double getHoursWorked() {
   return HoursWorked;
}

//TOSTRING METHOD

@Override
public String toString() {
   return "Hourly [PayRate=" + PayRate + ", HoursWorked=" +HoursWorked + "]";
}

double pay(){

return PayRate * HoursWorked;

}

}

//PIECE CLASS

public class Piece extends Employee {
   private int Quantity;
   private double PieceRate;
  
  
//CONSTRUCTORS
  
   public Piece() {
   // TODO Auto-generated constructor stub
}


public Piece(int quantity, double pieceRate) {
       super();
       Quantity = quantity;
PieceRate =pieceRate ;

}

//SETTERS FOR Quantity, pieceRate
public void setQuantity(int quantity) {
   Quantity = quantity;
}


public void setPieceRate(double pieceRate) {
PieceRate = pieceRate;
}
  

//GETTERS FOR PieceRate, Quantity
public int getQuantity() {
   return Quantity;
}

public double getPieceRate() {
   return PieceRate;
}

//TOSTRING METHOD

@Override
public String toString() {
   return "Piece [Quantity=" + Quantity + ", PieceRate=" +PieceRate + "]";
}

double pay(){

return Quantity * PieceRate;

}

}

//main function

public static void main(String[] args){

Employee employee[]= new Employee[20];

try{

File file=new File("https://easyupload.io/mpkorw");

BufferedReader br=new BufferedReader(new FileReader(file));

int r=0;  

while((r=br.read())!=-1)  

{  

//Code ssn first name last name address phone salary

//s 123-45-6789 William Tell 1313 Mockingbird lane 513-556-7058 500.75

Salaried s=new Employee();

Hourly h= new Employee();

Piece p=new Employee();

//group the employee types for the output

//keep them in the array of employee

}  

}  

catch(Exception e)  

{  

//file not found

e.printStackTrace();  

}

System.out.println("Dewey, Cheatem and How Law Firm");

System.out.println("Payroll Report");

System.out.println("Salaried Employees");

for(int i=0;i<employee.length; i++)

System.out.println("First Name : " +s.Firstname +" Last Name: " +s.Lastname+ "SSN : "+s.SSN + " Gross Pay:" + s.pay());

System.out.println("Hourly Employees");

for(int i=0;i<employee.length; i++)

System.out.println("First Name : " +h.Firstname +" Last Name: " +h.Lastname+ "SSN : "+h.SSN + " Gross Pay:" + h.pay());

System.out.println("Piecerate Employees");

for(int i=0;i<employee.length; i++)

System.out.println("First Name : " +p.Firstname +" Last Name: " +p.Lastname+ "SSN : "+p.SSN + " Gross Pay:" + p.pay());

}

Thank you. please upvote.


Related Solutions

Modify the Assignment program from Module 1 to read a user's first and last name read...
Modify the Assignment program from Module 1 to read a user's first and last name read three integer scores, calculate the total and average determine the letter grade based on the following criteria - Average 90-100 grade is A, 80-89.99 grade is B, 70-79.99 grade is C, all others F (use a nested if) Output formatted results consisting of the full name, the three scores, the total, average (to 2 decimal places), and the letter grade go to step 1...
Your task is to modify the program from the Java Arrays programming assignment to use text...
Your task is to modify the program from the Java Arrays programming assignment to use text files for input and output. I suggest you save acopy of the original before modifying the software. Your modified program should: contain a for loop to read the five test score into the array from a text data file. You will need to create and save a data file for the program to use. It should have one test score on each line of...
5. Modify the program for Line Numbers from L09: In-Class Assignment. Mainly, you are changing the...
5. Modify the program for Line Numbers from L09: In-Class Assignment. Mainly, you are changing the problem from using arrays to ArrayLists. There are some other modifications as well, so read the instructions carefully. The program should do the following: –Ask the user for how many lines of text they wish to enter –Declare and initialize an **ArrayList** of Strings to hold the user’s input –Use a do-while loop to prompt for and read the Strings (lines of text) from...
CS 1102 Unit 5 – Programming AssignmentIn this assignment, you will again modify your Quiz program...
CS 1102 Unit 5 – Programming AssignmentIn this assignment, you will again modify your Quiz program from the previous assignment. You will create an abstract class called "Question", modify "MultipleChoiceQuestion" to inherit from it, and add a new subclass of "Question" called "TrueFalseQuestion". This assignment will again involve cutting and pasting from existing classes. Because you are learning new features each week, you are retroactively applying those new features. In a typical programming project, you would start with the full...
Your assignment is to build a program that can take a string as input and produce...
Your assignment is to build a program that can take a string as input and produce a “frequency list” of all of the words in the string (see the definition of a word below.) For the purposes of this assignment, the input strings can be assumed not to contain escape characters (\n, \t, …) and to be readable with a single input() statement. When your program ends, it prints the list of words. In the output, each line contains of...
PYTHON Modify the program in section Ask the user for a first name and a last...
PYTHON Modify the program in section Ask the user for a first name and a last name of several people.  Use a loop to ask for user input of each person’s first and last names  Each time through the loop, use a dictionary to store the first and last names of that person  Add that dictionary to a list to create a master list of the names  Example dictionary: aDict = { "fname":"Douglas", "name":"Lee" } ...
JAVA Program: You are a developer for a company that wants to create a new payroll...
JAVA Program: You are a developer for a company that wants to create a new payroll system. Write a program that can be used to calculate an employee’s take home pay. Example - rmckanryProgram1. Creating a flow chart or using stump code to outline your program first may help. Include the following features in the program: Enter employee’s name Enter employee’s base hourly pay Enter the number of hours worked for the week Error if the hours worked exceeds 168...
Get the file “HW4Part4b.java” from the repository. Modify the program class to match the new file...
Get the file “HW4Part4b.java” from the repository. Modify the program class to match the new file name. Complete it by writing a recursive static int function named recur that is defined as follows: if i ≤ 0 or j ≤ 0, recur(i, j) = 0. if i = j, recur(i, j) = i. if i > j, recur(i, j) = j. In all other cases, recur(i, j) = 2 · recur(i − 1, j) + recur(j − 1, i) Add...
how you would implement a new payroll system for a large retail organization that will take...
how you would implement a new payroll system for a large retail organization that will take affect in 6 months. This new system would replace the current system where employees manually turn in time sheets to their supervisors at the end of each week with their hours worked. The new automated system would require finger print identification to clock in and out of the system.
In Python b) Modify your program that reads 3 grades from the user (and computes the...
In Python b) Modify your program that reads 3 grades from the user (and computes the average and letter grade) so that it uses a while loop to read the 3 grades. In the loop body, you will just read one grade and update other variables appropriately. The loop header will ensure 3 iterations. c) Modify your program in part b so that it asks the user how many grades there are and uses a while loop to read that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT