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

Directions Points The file must be called <Payroll.java> (driver program) Employ

ID: 3542047 • Letter: D

Question

Directions Points

The file must be called <Payroll.java> (driver program)

Employee.java

Hourly.java (which extends employee)

Salaried.java (which extends employee)

SalariedPlusCommission.java (which extends Salaried)

Ensure you include ALL files required to make your program compile and run.

I would like to see your .java files only.

Proper coding conventions required the first letter of the class start with a capital

letter and the first letter of each additional word start with a capital letter.


Overall Requirements

Write an employee payroll program that uses polymorphism to calculate and print the

weekly payroll for your company. There are three types of employees ? hourly,

salaried, and salaried plus commission. Each type of employee gets paid using a

different formula. But for all employee types, if the calculated paycheck exceeds

$1000, the actual paycheck must be decreased to $1000.


Use the public access modifier for the toString method in the Employee class and

the load method in the Employee, Hourly, Salaried, and SalariedPlusCommission

classes.


Employee.java class

Instance variables:

name

social security number

birthday month

birthday week

load method :

Prompts the user for instance-variable values and loads the entries.

toString method:

Returns a string that shows the employee

Explanation / Answer

import java.io.*;

import java.util.ArrayList;

import java.lang.*;

public class Payroll {

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

String input, name;

ArrayList employ;

double hours;

int e;

public Payroll()throws IOException{

employ=new ArrayList();

getInput();

}


private void getInput()throws IOException{

int count=0;

e=Integer.parseInt(br.readLine());

do{

input=br.readLine();

name=getName(input);

hours=getWage(input);

employ.add(new Employee(name, hours));

count++;

}while(count<e);

System.out.println();


count=0;

e=Integer.parseInt(br.readLine());

do{

input=br.readLine();

for(int i=0;i<employ.size();i++){

Employee m=(Employee)employ.get(i);


if(getName(input).equals(m.getName()))

m.addHours(getHours(input));

}

count++;

}while(count<e);


display();

}


private void display(){

for(int i=0;i<employ.size();i++){

Employee m=(Employee)employ.get(i);

System.out.println(m.getName()+", "+m.getHours()+" Hours, $"+m.getPay());

}

}

private double getWage(String n){

double r=0;

String temp="";

int x=0;

while(n.charAt(x)!=32){

x++;

}

for(int i=x+1;i<n.length();i++){

temp+=Character.toString(n.charAt(i));

}

r=Double.parseDouble(temp);

return r;

}


private double getHours(String n){

double r=0;

String temp="";

int x=0;

while(n.charAt(x)!=32){

x++;

}

for(int i=x+1;i<n.length();i++){

temp+=Character.toString(n.charAt(i));

}

r=Double.parseDouble(temp);

r/=60;

return r;

}



private String getName(String n){

String s="";

int x=0;

while(n.charAt(x)!=32){

s+=Character.toString(n.charAt(x));

if(x<n.length())

x++;

else

break;

}

return s;

}

}

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