5)Â Â Â Â Â You have been appointed the chief IT manager of Housing Finance Corporation. At the moment, the operations are manual and the management would like you to automate them.
Assume the following details:
Ø Employees Names
Ø Box Number
Ø Town
Ø Personnel Number
Ø Department
Ø Basic Salary
Ø Consolidated Allowances
Required:
i) Write a JAVA class declaration for the above.                                                  (6 mks)
ii) Write appropriate function definitions.                                                          (5 mks)
iii) Write the appropriate driver program (main function
import java.util.ArrayList;
import java.util.Arrays;
public class HousingFinanceCorporation {
private ArrayList<String> employeesNames = new ArrayList<>();
private int boxNumber;
private String town;
private int personnelNumber;
private String department;
private double basicSalary;
private ArrayList<Integer> consolidatedAllowances = new ArrayList<>();
public void setEmployeesNames(String emplN){
this.employeesNames.add(emplN);
}
public void setBoxNumber(int boxN){
this.boxNumber = boxN;
}
public void setTown(String town){
this.town = town;
}
public void setPersonnelNumber(int persN){
this.personnelNumber = persN;
}
public void setDepartment(String dep){
this.department = dep;
}
public void setBasicSalary(double basicS){
this.basicSalary = basicS;
}
public void setConsolidatedAllowances(int consAll){
this.consolidatedAllowances.add(consAll);
}
public ArrayList<String> getEmployeesNames(){
return this.employeesNames;
}
public int getBoxNumber(){
return this.boxNumber;
}
public String getTown(){
return this.town;
}
public int getPersonnelNumber(){
return this.personnelNumber;
}
public String getDepartment(){
return this.department;
}
public double getBasicSalary(){
return this.basicSalary;
}
public ArrayList<Integer> getConsolidatedAllowances(){
return this.consolidatedAllowances;
}
public static void main(String args[]){
HousingFinanceCorporation housingFinanceCorporation = new HousingFinanceCorporation();
housingFinanceCorporation.setEmployeesNames("Elisa Fox");
housingFinanceCorporation.setEmployeesNames("Bill Harris");
housingFinanceCorporation.setBoxNumber(1234567800);
housingFinanceCorporation.setTown("London");
housingFinanceCorporation.setPersonnelNumber(2);
housingFinanceCorporation.setDepartment("Sales");
housingFinanceCorporation.setBasicSalary(4560.99);
housingFinanceCorporation.setConsolidatedAllowances(5);
housingFinanceCorporation.setConsolidatedAllowances(10);
System.out.println("Employees Names: " + housingFinanceCorporation.getEmployeesNames());
System.out.println("Box Number: " + housingFinanceCorporation.getBoxNumber());
System.out.println("Town: " + housingFinanceCorporation.getTown());
System.out.println("Personnel Number: " + housingFinanceCorporation.getPersonnelNumber());
System.out.println("Department: " + housingFinanceCorporation.getDepartment());
System.out.println("Basic Salary " + housingFinanceCorporation.getBasicSalary());
System.out.println("Consolidated Allowances as a percentage: " + housingFinanceCorporation.getConsolidatedAllowances());
}
}
Comments
Leave a comment