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

Create a class Employee that has the attributes first name, last name, Job title

ID: 3699264 • Letter: C

Question

Create a class Employee that has the attributes first name, last name, Job title, salary, phone number, address, and Employee ID. First name, last name, and address are all of type string, salary is of type double, and phone number is of type integer. ID must be defined as a separate It has an 8-digit number that consists of three parts. The first digit (left to right) represent the century of employment if it was before 2000 then it is 1 else it is 2 then the second two digits represent the year of employment. The last 5 digits represents a serial number. JobTitle is of type enum, each type has job title code (String) and hour wage (double) that is related to that code. The types are listed in the following table: Job Tiale Job Title Code Hour Wage Consultant C ProjectManager PM EngineerENG Technician TECH Coordinatr CORD You should create an application class Employeelnfo that asks the user to enter the number of employees he/she wishes to input/view, create a reference array of type Employee, enter employees' information and then view the information of all the employee entered. The job title is entered as a code. For the salary, the program should ask the user to enter the number of projects the employee has worked on this month, and then the number of hours he worked on each of the projects. The program then calculates the salary using the following formula: The hourly age is taken from the JobTitle Enumeration Sample Run Enter the number of employees: 3 Employee 1 First Name: Ali Employee 1 Last Name: Mohammed Employee 1 Job Title Code: TECH Employee 1 Phone Number: 9987010 Employee 1 Address: KuwaitBlock 12 Employee 1 Year of Employment: 1998 Employee 1 Number of projects: 3 Employee 1 Project 1 hours: 20 Employee 1 Project 2 hours: 50 Employee 1 Project 3 hours: 20 Employee 2 First Name: Raef Employee 2 Last Name: Jawad Employee 2 Job Title Code: ENG Employee 2 Phone Number: 9987111 Employee 2 Address: Heshref Block 1 Employee 2 Year of Employment: 2000

Explanation / Answer

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class EmployeeInfo {

   public static void main(String[] args) {

       List<Employee> employeeList = new ArrayList<Employee>();

       Scanner scanner = new Scanner(System.in);

       System.out.println("Enter the number of employees: ");

       int employeesCount = scanner.nextInt();

       for (int i = 0; i < employeesCount; i++) {

           Employee employee = new Employee();

           System.out.println("Employee "+i+1+" First Name:");

           String firstName = scanner.nextLine();

           System.out.println("Employee "+i+1+" Last Name:");

           String lastName = scanner.nextLine();

           System.out.println("Employee "+i+1+" Job Title Code:");

           String titleCode = scanner.nextLine();

           System.out.println("Employee "+i+1+" Phone Number:");

           int phoneNumber = scanner.nextInt();

           System.out.println("Employee "+i+1+" Address:");

           String address = scanner.nextLine();

           System.out.println("Employee "+i+1+" Year Of Employment:");

           int year = scanner.nextInt();

           System.out.println("Employee "+i+1+" Number of projects:");

           int projectCount = scanner.nextInt();

           int totalHours = 0;

           for (int j = 0; j < projectCount; j++) {

               System.out.println("Employee "+i+1+" Project "+j+1+" hours:");

               int hours = scanner.nextInt();

               totalHours += hours;

           }

           employee.setFirstName(firstName);

           employee.setLastName(lastName);

           employee.setJobTitle(JobTitle.valueOf(titleCode));

           employee.setAddress(address);

           employee.setPhoneNumber(phoneNumber);

           StringBuffer sb = new StringBuffer();

           if (year < 2000) {

               sb.append("1");

           } else {

               sb.append("2");

           }

           sb.append(year%100);

           if (i+1 < 10) {

               sb.append("0000").append(i+1);

           } else if (i+1 < 100) {

               sb.append("000").append(i+1);

           }

           EmployeeID employeeID = new EmployeeID(sb.toString());

           employee.setEmployeeID(employeeID);

           double salary = totalHours * employee.getJobTitle().getHourWage();

           employee.setSalary(salary);

          

           employeeList.add(employee);

           System.out.println();

       }

      

       System.out.println("Employees Are:");

       for (int i = 0; i < employeesCount; i++) {

           Employee employee = employeeList.get(i);

           System.out.println("Name "+i+1+": "+employee.getFirstName()+" "+employee.getLastName());

           System.out.println("ID: "+employee.getEmployeeID().id);

           System.out.println("Phone Number: "+employee.getPhoneNumber());

           System.out.println("Address: "+employee.getAddress());

           System.out.println("Job Title: "+employee.getJobTitle().toString());

           System.out.println("Hour wage: "+employee.getJobTitle().getHourWage());

           System.out.println("Salary: "+employee.getSalary());

           System.out.println();

       }

   }

}

class Employee {

   String firstName;

   String lastName;

   JobTitle jobTitle;

   double salary;

   int phoneNumber;

   String address;

   EmployeeID employeeID;

  

   public String getFirstName() {

       return firstName;

   }

   public void setFirstName(String firstName) {

       this.firstName = firstName;

   }

   public String getLastName() {

       return lastName;

   }

   public void setLastName(String lastName) {

       this.lastName = lastName;

   }

   public JobTitle getJobTitle() {

       return jobTitle;

   }

   public void setJobTitle(JobTitle jobTitle) {

       this.jobTitle = jobTitle;

   }

   public double getSalary() {

       return salary;

   }

   public void setSalary(double salary) {

       this.salary = salary;

   }

   public int getPhoneNumber() {

       return phoneNumber;

   }

   public void setPhoneNumber(int phoneNumber) {

       this.phoneNumber = phoneNumber;

   }

   public String getAddress() {

       return address;

   }

   public void setAddress(String address) {

       this.address = address;

   }

   public EmployeeID getEmployeeID() {

       return employeeID;

   }

   public void setEmployeeID(EmployeeID employeeID) {

       this.employeeID = employeeID;

   }

}

class EmployeeID {

   String id;

   public EmployeeID(String id) {

       super();

       this.id = id;

   }

}

enum JobTitle {

   Consultant("C", 30), ProjectManager("PM", 20), Engineer("ENG", 17.5), Technician("TECH",15), Worker("W", 10), Driver("D", 10), Coordinator("CORD", 12.5);

   private String code;

   private final double hourWage;

   JobTitle(String code, double hourWage) {

       this.code = code;

       this.hourWage = hourWage;

   }

   public String getCode() {

       return code;

   }

   public void setCode(String code) {

       this.code = code;

   }

   public double getHourWage() {

       return hourWage;

   }

}

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