Question: Create an Employee class and an EmployeeDemo class with the specifications described below. The EMPLOYEE_NUMBER_SEED is a static field. This means that the value is

Create an Employee class and an EmployeeDemo class with the specifications described below.

The EMPLOYEE_NUMBER_SEED is a static field. This means that the value is shared across ALL Employee objects created within a program while it is running. All Employee objects share that data field, and it only has one memory location for all objects. If one Employee object changes the value when the program is running, it changes for ALL Employee objects in that program.

Employee class

The Employee class should contain the following private data fields:

  • static int EMPLOYEE_NUMBER_SEED = 100000;
  • employeeNumber (int)
  • lastName (String)
  • firstName (String)
  • salary (double)

The Employee class should contain a constructor that:

  • Takes the lastname, firstname, and salary as parameters.
  • Sets the employeeNumber = EMPLOYEE_NUMBER_SEED
  • Increases the EMPLOYEE_NUMBER_SEED by 1.

The Employee class should contain the following additional public methods:

  • accessor (get) and mutator (set) methods for all instance variables (non-static).
  • giveRaise() method that takes an percentage that the employees salary should be increased and applies it to the salary.

EmployeeDemo class

The Employee demo class should contain the following methods:

  • A static askUser() method that prompts the user for the employees firstname, lastname, and salary, creates an Employee object using your constructor, and returns the object back to the main() method.
  • A static askRaise() method that will ask the user how percentage raise ALL employees will receive and return that as a decimal value (if user enters 8, return .08) to the main() method.
  • A static display() method that will display the contents of the object.
  • The main() method should create 3 Employee objects using the askUser() method, apply the raise to all 3 Employee objects, then print out all Employee objects with the NEW salaries, preferably formatted in a column format.
Written in Java

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!