The solution provides code for an employee payroll program. It includes classes for Employee, Company, and EmployeeDemo (the main class). EmployeeDemo gets input for multiple employees and uses the Employee class to calculate payroll values like taxes, wages, deductions. It then passes the data to the Company class which collects overall payroll statistics.
Introduction to ArtificiaI Intelligence in Higher Education
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
1. The solution is as below:
EmployeeDemo.java
import java.util.Scanner;
public class EmployeeDemo
{
static Scanner scan = new Scanner(System.in);
public static void main(String[] args)
{
Company clerk = new Company( );
Employee employee = new Employee();// one student
int count,dependent;
String fname,lname;
float hourly_rate,no_of_hours,l_tax,f_tax,s_tax;
System.out.println("Enter number of employees:");
int numberOfEmployees = scan.nextInt();
for (count = 0; count < numberOfEmployees; count++)
{
System.out.println("Enter data for employee number " + count);
System.out.println("First Name ");
fname = scan.next();
System.out.println("Last Name ");
lname = scan.next();
System.out.println("Number of dependents ");
dependent = scan.nextInt();
System.out.println("Hourly rate ");
hourly_rate = scan.nextFloat();
System.out.println("Number of hours worked ");
no_of_hours = scan.nextFloat();
System.out.println("Local tax withheld to date ");
l_tax = scan.nextFloat();
System.out.println("Federal tax withheld to date ");
f_tax = scan.nextFloat();
System.out.println("State tax withheld to date ");
s_tax = scan.nextFloat();
8. }
public float getT_deduction() {
return t_deduction;
}
public void setT_deduction(float t_deduction) {
this.t_deduction = t_deduction;
}
public float getG_wages() {
return g_wages;
}
public void setG_wages(float g_wages) {
this.g_wages = g_wages;
}
public float getNet_pay() {
return net_pay;
}
public void setNet_pay(float net_pay) {
this.net_pay = net_pay;
}
public float getCf_tax() {
return cf_tax;
}
public void setCf_tax(float cf_tax) {
this.cf_tax = cf_tax;
}
public float getCs_tax() {
return cs_tax;
}
public void setCs_tax(float cs_tax) {
this.cs_tax = cs_tax;
}
public float getCt_deduction() {
return ct_deduction;
}
public void setCt_deduction(float ct_deduction) {
this.ct_deduction = ct_deduction;
9. }
public void colectDataForCompanyReport(Employee employee, int i) {
// TODO Auto-generated method stub
for(int j=0 ; j
Solution
The solution is as below:
EmployeeDemo.java
import java.util.Scanner;
public class EmployeeDemo
{
static Scanner scan = new Scanner(System.in);
public static void main(String[] args)
{
Company clerk = new Company( );
Employee employee = new Employee();// one student
int count,dependent;
String fname,lname;
float hourly_rate,no_of_hours,l_tax,f_tax,s_tax;
System.out.println("Enter number of employees:");
int numberOfEmployees = scan.nextInt();
for (count = 0; count < numberOfEmployees; count++)
{
System.out.println("Enter data for employee number " + count);
System.out.println("First Name ");
fname = scan.next();
System.out.println("Last Name ");
lname = scan.next();
System.out.println("Number of dependents ");
dependent = scan.nextInt();
System.out.println("Hourly rate ");
hourly_rate = scan.nextFloat();
System.out.println("Number of hours worked ");
no_of_hours = scan.nextFloat();
System.out.println("Local tax withheld to date ");
l_tax = scan.nextFloat();
10. System.out.println("Federal tax withheld to date ");
f_tax = scan.nextFloat();
System.out.println("State tax withheld to date ");
s_tax = scan.nextFloat();
employee.readInput(fname,lname,dependent,hourly_rate,no_of_hours,l_tax,f_tax,s_tax);
employee.calculateData(count);
employee.writeOutput(count);
clerk.colectDataForCompanyReport(employee,count);
}
clerk.printDataForCompanyReport();
}
}
Employee.java
import java.util.ArrayList;
public class Employee {
private ArrayList fname,lname;
private ArrayList dependent;
private ArrayList
hourly_rate,no_of_hours,l_tax,f_tax,s_tax,g_wages,cf_tax,cl_tax,cs_tax,t_tax,ct_tax,net_pay;
public Employee(){
fname = new ArrayList();
lname = new ArrayList();
dependent = new ArrayList();
hourly_rate = new ArrayList();
no_of_hours = new ArrayList();
l_tax = new ArrayList();
f_tax = new ArrayList();
s_tax = new ArrayList();
g_wages = new ArrayList();
cl_tax = new ArrayList();
cf_tax = new ArrayList();
cs_tax = new ArrayList();
t_tax = new ArrayList();
11. ct_tax = new ArrayList();
net_pay = new ArrayList();
}
public ArrayList getFname() {
return fname;
}
public void setFname(ArrayList fname) {
this.fname = fname;
}
public ArrayList getLname() {
return lname;
}
public void setLname(ArrayList lname) {
this.lname = lname;
}
public ArrayList getDependent() {
return dependent;
}
public void setDependent(ArrayList dependent) {
this.dependent = dependent;
}
public ArrayList getHourly_rate() {
return hourly_rate;
}
public void setHourly_rate(ArrayList hourly_rate) {
this.hourly_rate = hourly_rate;
}
public ArrayList getNo_of_hours() {
return no_of_hours;
}
public void setNo_of_hours(ArrayList no_of_hours) {
this.no_of_hours = no_of_hours;
}
12. public ArrayList getL_tax() {
return l_tax;
}
public void setL_tax(ArrayList l_tax) {
this.l_tax = l_tax;
}
public ArrayList getF_tax() {
return f_tax;
}
public void setF_tax(ArrayList f_tax) {
this.f_tax = f_tax;
}
public ArrayList getS_tax() {
return s_tax;
}
public void setS_tax(ArrayList s_tax) {
this.s_tax = s_tax;
}
public ArrayList getG_wages() {
return g_wages;
}
public void setG_wages(ArrayList g_wages) {
this.g_wages = g_wages;
}
public ArrayList getCf_tax() {
return cf_tax;
}
public void setCf_tax(ArrayList cf_tax) {
this.cf_tax = cf_tax;
}
public ArrayList getCl_tax() {
return cl_tax;
}
public void setCl_tax(ArrayList cl_tax) {
this.cl_tax = cl_tax;
}
13. public ArrayList getCs_tax() {
return cs_tax;
}
public void setCs_tax(ArrayList cs_tax) {
this.cs_tax = cs_tax;
}
public ArrayList getT_tax() {
return t_tax;
}
public void setT_tax(ArrayList t_tax) {
this.t_tax = t_tax;
}
public ArrayList getCt_tax() {
return ct_tax;
}
public void setCt_tax(ArrayList ct_tax) {
this.ct_tax = ct_tax;
}
public ArrayList getNet_pay() {
return net_pay;
}
public void setNet_pay(ArrayList net_pay) {
this.net_pay = net_pay;
}
public void readInput(String fname2, String lname2, int dependent2, float hourly_rate2, float
no_of_hours2, float l_tax2, float f_tax2, float s_tax2){
this.fname.add(fname2);
this.lname.add(lname2);
this.dependent.add(dependent2);
this.hourly_rate.add(hourly_rate2);
this.no_of_hours.add(no_of_hours2);
this.l_tax.add(l_tax2);
this.f_tax.add(f_tax2);
this.s_tax.add(s_tax2);
}