Question: Objective : The purpose of this assignment is to introduce Classes. Task : An employee in a company is identified by ID, name, employment type,

Objective:

The purpose of this assignment is to introduce Classes.

Task:

An employee in a company is identified by ID, name, employment type, number of worked hours, rate per hour and salary. Write Java program to create EmployeeInfo Class with the aforementioned attributes. Once an employee object is created, all attributes should be possible to modify. Thus, you must include all needed setter and getter functions in the class (dont use one function to set all values). An employee object must include the following member methods:

  • Default Constructor that initializes attributes to default values.
  • Full Constructor that initializes attributes to the passed parameters values.
  • Partial Constructor that initializes only the ID, name and employment type.
  • Setters and Getters.
  • toString( )
  • cal _Salary function that calculate and returns the total salary of the employee per week
    • If the employee type is a part time, then:

SALARY=RATE_PER_HOUR* NUMBER_OF_HOURS_WORKED_PER_WEEK

  • If the employee is a full time, then:

SALARY=500+(NUMBER_OF_HOURS_WORKED_PER_WEEK-38)*RATE_PER_HOUR

  • display_Employee_Info, which displays the employees information (ID, Name, Gender, Type, and Salary)

In the main (Driver Method):

  1. Create two Employee objects with the full constructor.

ID

NAME

TYPE

RATE

HOURS

111

Ahmad

Full

35

40

222

Khalid

Part

30

32

  1. Create 3rd employee object with the default constructor.
  2. Modify the attributes of the object according to the following table by calling setter methods.

ID

NAME

TYPE

RATE

HOURS

333

Sara

Full

35

45

  1. Create 4th employee object with the partial constructor.
  2. Modify the attributes of the object according to the following table through the standard input (keyboard)

ID

NAME

TYPE

RATE

HOURS

444

Amal

Full

35

38

  1. Use toString method to print all the employees information with no salary.
  2. Calculate the salary for the 4 employees.
  3. Print all the employees information with their salaries by calling the method display_Employee_Info.

Extra Task (not to be submitted):

  1. Create an array and add all the employees objects to it.
  2. Display the third element in the array.

Sample output:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!