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

Create a Java application, that support the following: Create an Employee class,

ID: 3693215 • Letter: C

Question

Create a Java application, that support the following:

Create an Employee class, which holds following information:

Employee First Name

Employee Last Name

Employee Phone Number

Employee Address

Employee id

Employee Title

Employee salary

CreateCreate an application that uses the Employee classConstructors –Getters and setters

A minimum of 3 constructors including default constructor

equals() method

Helper methods

toString() method

Create an array of 5 Employee objects

Use a Scanner to read in 5 employee information

Change 2 employees information (3-items each)

Create an Employee report at the end using appropriate class methods, to generate the report

---- Please include the following -----

Captured output (use <CTL><prt sc> to capture the output

UML Diagram with relationships

Flow Chart

Make sure your code if commented well

Make sure your code is indented correctly

Javadoc

Explanation / Answer

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

public class Employee{

    String firstName;
    String lastName;
    String phoneNumber;
    String address;
    int id;
    String title;
    double salary;

    //default constructor
    public Employee(){}
  
    // This is the constructor of the class Employee
    public Employee(String fnameint eid){
        this.firstName = fname;
        this.id=eid;
    }

    // This is the constructor of the class Employee
    public Employee(String fname,String lname,String number,String addr,int eid,String etitle,double sal){
        this.firstName = fname;
        this.lastName =lname;
        this.phoneNumber = number;
        this.address =addr;
        this.id=eid;
        this.title= etitle;
        this.salary =sal;
    }
    // Assign the firstname of the Employee to the variable firstname.
    public void setFirstName(String fname){
        firstName = fname;
    }
    // Assign the lastName of the Employee to the variable lastName.
    public void setLastName(String lname){
        lastName = lname;
    }
    // Assign the phonenumber of the Employee to the variable phonenumber.
    public void setPhoneNumber(String number){
        phoneNumber = number;
    }
    // Assign the address of the Employee to the variable address.
    public void setAddress(String add){
        address = add;
    }
    // Assign the id of the Employee to the variable id.
    public void setId(int eid){
        id = eid;
    }

    // Assign the title to the variable title.
    public void setTitle(String etitle){
        title = etitle;
    }
    // Assign the salary to the variable salary.
    public void setSalary(double empSalary){
        salary = empSalary;
    }

    // get the firstname of the Employee
    public String getFirstName(){
        return firstName;
    }
    // get the lastName of the Employee
    public String getLastName(){
        return lastName;
    }
    // get the phonenumber of the Employee
    public String getPhoneNumber() {
        return phoneNumber;
    }
    // get the salary of the Employee
    public double getSalary() {
        return salary;
    }
    // get the id of the Employee
    public int getId() {
        return id;
    }
    // get the address of the Employee
    public String getAddress() {
        return address;
    }
    // get the title of the Employee
    public String getTitle() {
        return title;
    }

    // Overriding equals() to compare two Employee objects
    @Override
    public boolean equals(Object o) {

        // If the object is compared with itself then return true
        if (o == this) {
            return true;
        }

        /* Check if o is an instance of Complex or not
          "null instanceof [type]" also returns false */
        if (!(o instanceof Employee)) {
            return false;
        }
        return false;
    }

    public String toString() {
        return "Name of the Employee: " + this.firstName + " " +this.lastName + ", PhoneNumber: "+this.phoneNumber
                + ", Address :" + this.address + ", Title: "+ this.title+", id: "+this.id+", Salary: "+ this.salary;
    }

    public static void main(String args[]){

        String fname,lname,phonenumber,address,title;
        int id;
        double salary;
        Employee e1 = null;
        Employee e2 = null;
        Employee e3 = null;
        Employee e4 = null;
        Employee e5 = null;
        Scanner input = new Scanner(System.in);

        for (int i=0;i<5;i++) {
            System.out.println("Please enter Employee-"+(i+1)+" firstname : ");
            fname = input.next(); // getting a String value

            System.out.println("Please enter Employee-"+(i+1)+" lastname : ");
            lname = input.next(); // getting an String value

            System.out.println("Please enter Employee-"+(i+1)+" phoneNumber : ");
            phonenumber = input.next();

            System.out.println("Please enter Employee-"+(i+1)+" address : ");
            address = input.next(); // getting an String value

            System.out.println("Please enter Employee-"+(i+1)+" id : ");
            id = input.nextInt(); // getting an int value

            System.out.println("Please enter Employee-"+(i+1)+" title : ");
            title = input.next(); // getting an String value

            System.out.println("Please enter Employee-"+(i+1)+" salary : ");
            salary = input.nextDouble(); // getting an Double value

            if(i==0){
                e1= new Employee(fname,lname,phonenumber,address,id,title,salary);
            } else if(i==1){
                e2= new Employee(fname,lname,phonenumber,address,id,title,salary);
            } else if(i==2){
                e3= new Employee(fname,lname,phonenumber,address,id,title,salary);
            } else if(i==3){
                e4= new Employee(fname,lname,phonenumber,address,id,title,salary);
            } else if(i==4){
                e5= new Employee(fname,lname,phonenumber,address,id,title,salary);
            }
        }

    }
}