Question: Write a class named Employee that has the following fields / variables: name - The name field references a String object that holds the employee
Write a class named Employee that has the following fieldsvariables:
name The name field references a String object that holds the employees name.
idNumber The idNumber is an int variable that holds the employees ID number.
department The department field references a String object that holds the name of the department where the employee works.
position The position field references a String object that holds the employees job title.
salary The salary is a double variable that holds the employee's monthly salary.
The class must have the following three constructors:
A constructor that accepts the following values as arguments and assigns them to the appropriate fields: employees name, employees ID number, department, position, and salary.
A constructor that accepts the following values as arguments and assigns them to the appropriate fields: employees name, ID number, and monthly salary. The department and position fields should be assigned an empty string
A noarg constructor that assigns empty strings to the name, department, and position fields, and to the idNumber and salary field.
Write appropriate mutator methods that store values in these fields and accessor methods that return the values in these fields. Once you have written the class, write a separate programthis part is given below that creates three Employee objects to hold the following data: data is in the table The program should store this data in the three objects and then display the data for each employee on the screen. The main function that creates these three objects is given below. Without modifying this given code, write a class named Employee that will work with this file:
This main function is a partial a solution to the
Employee Class programming challenge. Do not change
this given code. You have to write your own Employee class.
public class Main
public static void mainString args
Create the first employee. Use the noarg constructor.
Employee employee new Employee;
employeesetNameJames Wilson";
employeesetIdNumber;
employeesetDepartmentAccounting;
employeesetPositionVice President";
employeesetSalary;
Create the second employee. Use the constructor that accepts arguments for
all of the fields.
Employee employee new EmployeeMary Garcia", IT "Programmer", ;
Create the third employee. Use the constructor
that accepts the name and ID number. Rest of the
member variables need to be initialized by the
third overloaded constructor
Employee employee new EmployeeRobert Miller", ;
employeesetDepartmentManufacturing;
employeesetPositionVolunteer;
Display the data for employee
System.out.printlnEmployee #;
System.out.printlnName: employeegetName;
System.out.printlnID Number: employeegetIdNumber;
System.out.printlnDepartment: employeegetDepartment;
System.out.printlnPosition: employeegetPosition;
System.out.printlnYearly Salary: employeegetYearlySalary;
System.out.println;
Display the data for employee
System.out.printlnEmployee #;
System.out.printlnName: employeegetName;
System.out.printlnID Number: employeegetIdNumber;
System.out.printlnDepartment: employeegetDepartment;
System.out.printlnPosition: employeegetPosition;
System.out.printlnYearly Salary: employeegetYearlySalary;
System.out.println;
Display the data for employee
System.out.printlnEmployee #;
System.out.printlnName: employeegetName;
System.out.printlnID Number: employeegetIdNumber;
System.out.printlnDepartment: employeegetDepartment;
System.out.printlnPosition: employeegetPosition;
System.out.printlnYearly Salary: employeegetYearlySalary;
System.out.println;
Following is the exact output you should get:
Employee #
Name: James Wilson
ID Number:
Department: Accounting
Position: Vice President
Yearly Salary:
Employee #
Name: Mary Garcia
ID Number:
Department: IT
Position: Programmer
Yearly Salary:
Employee #
Name: Robert Miller
ID Number:
Department: Manufacturing
Position: Volunteer
Yearly Salary:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
