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

The objectives of this assignment are to: 1. Gain a furth er understanding and e

ID: 3723807 • Letter: T

Question

The objectives of this assignment are to: 1. Gain a furth er understanding and experience in the use of the Eclipse IDE for Java understanding of arrays and the use of control statements to process arrays. 3. Gain an understanding and experience in the use of arrays of objects 4. Gain an understanding and experience in reading sequential text files. Your company has asked you to develop a report detailing payroll information with the following format: Acme Corporation Number of Employees: Average Salary: Annual Total: 53,502.32 160,506.95 Salary A3 65,eee.ee Name Jones, William B2 42, 500.00 Rank Baker, Susan Baer, Teddy B4 53,006.95 Develop an Employee class that contains first name, last name, rank, and salary. The class should have the following methods: parameterized constructor getters necessary for printing the report formatName() method that returns a String with the name in the format last, first Employee information is stored in a sequential text file named employees. txt·The file has the format: employees.txt file: text file with the following fields separated by spaces: Fields First Name Last Name Rank Sala Description string string string double Note: Names will not contain spaces. Write a program named Prog5 that reads employee information from the file and places a corresponding Employee object into an array. After the file has been read, print the report shown above using proper formatting.

Explanation / Answer

here is your files : ------------>>>>>>>..

Employee.java : ---------->>>>>>>

public class Employee{
private String fname;
private String lname;
private String rank;
private double salary;

public Employee(String f,String l,String r,double s){
  fname = f;
  lname = l;
  rank = r;
  salary = s;
}

public Employee(){
  fname = "";
  lname = "";
  rank = "";
  salary = 0.0;
}

public void setFirstName(String f){
  fname = f;
}

public void setLastName(String l){
  lname = l;
}

public void setRank(String r){
  rank = r;
}

public void setSalary(double s){
  salary = s;
}

public String getFirstName(){
  return fname;
}
public String getLastName(){
  return lname;
}
public String getRank(){
  return rank;
}

public double getSalary(){
  return salary;
}

public String formatName(){
  return lname+", "+fname;
}

}

Record.java : ----------->>>>>>>>>>>

import java.io.*;
import java.util.*;

public class Record{
public static void main(String[] args) {
  ArrayList<Employee> records = new ArrayList<>();
  Scanner sc;
  try{
   sc = new Scanner(new File("employees.txt"));
   String line;
   while(sc.hasNextLine()){
    line = sc.nextLine();
    String[] str = line.split(" ");
    Employee temp = new Employee();
    if(str.length == 4){
     temp.setFirstName(str[0]);
     temp.setLastName(str[1]);
     temp.setRank(str[2]);
     temp.setSalary(Double.parseDouble(str[3]));
    }

    if(str.length == 3){
     String[] name = str[0].split(",");
     temp.setFirstName(name[0]);
     temp.setLastName(name[1]);
     temp.setRank(str[2]);
     temp.setSalary(Double.parseDouble(str[3]));
    }

    records.add(temp);
   }
  }catch(Exception e){
   e.printStackTrace();
  }

  System.out.println("Acme Corporation ------------------------------------------------------------------");
  System.out.println("Number of Employees = "+records.size());
  double total = 0.0;
  for(int i = 0;i<records.size();i++){
   total = total + records.get(i).getSalary();
  }
  System.out.println("Avarage Salary : "+(total/records.size()));
  System.out.println("Annual Total : "+total);

  System.out.println("Name      Rank       Salary");
  for(int i = 0;i<records.size();i++){
   System.out.println(""+records.get(i).formatName()+"   "+records.get(i).getRank()+"   "+records.get(i).getSalary());
  }
}
}

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