Problem Description: Expand the Student Class

For this Lab your task is to create a class Employee. Employee class should have the following instance variables: empID, empName, empSalary, emplJob,empRating that store the employees ID, name, salary, job title, and number indicating the performance of the employee respectively. You should also supply a constructor and the following methods: getempID(), getempSalary(),getName(), setempSalary(), setempJob(), raiseempSalary().

Step 1: Getting Started:

First, you need to create an Employee class and declare class as follows

class Employee {

Inside the class Employee, you will be declaring the following data members to store employees information: a String variable empName, an integer empID, a double empSalary, a String empJob and an int empYears.

// declare some variables of different types:
// a String called empName
//-->
// an int called empID
//-->
// a String called empJob
//-->
// a double called empSalary
//-->
// an int called empRating
//-->

Step 3: Defining the constructor

public Employee (String employeeName, int employeeID, int employeeRating)
{
// write the segment of code
//that assigns input data to the data members
}

Step 4: Adding the methods

You will need to create the following getter and setter methods:

int getempID()
String getName()
double getempSalary()
void setempSalary(double salary)
void setempJob(String jobTitle)

These getter and setter methods are quite similar to the ones we created for Lab 7 and Lab 8. Refer to the Lab 7 and Lab 8 handout for the creation and function of getter and setter methods.

In addition to the getter and setter methods, you will create an additional method that raises the salary of the employee based on the performance of the employee. Here is the logic to implement the raiseSalary() class:

If the number indicating the performance of the employee is 1, employee will receive a raise of 4%.

If the number indicating the performance of the employee is 2, employee will receive a raise of 2%.

If the number indicating the performance of the employee is 3, employee will not receive a raise.

void raiseSalary() {
//finish implementing the raiseSalary method
if (empRating==1){
empSalary= empSalary+ (empSalary*0.04)
}
-->
}

Step 5: Calling the constructor and using the methods of the Employee class from the main method

The final task of this lab is use Employee class variables and methods. In order to do so, we need to have a runner function. Remember, for any class in java, main method will be the running method.

public class Lab9 {
public static void main(String[] args) {
// Create a new Scanner object to take in input from the user.
// ->
// Prompt the user for the employee’s name
// ->
// Prompt the user for the employee’s ID
// ->
// Prompt the user for employee’s rating.
// ->
// create a new Employee object using the name,
// id, job, salary, and rating given by the user
//-->
//Since we did not prompt for job title
// use the setempJob(String jobTitle) to set the job to
//Software Engineer
// -->
//Since we did not prompt for employee’s salary
// use the setempSalary(double salary) to set the salary to
//4000.00
// ->
// Print out the Employee’s information in the
// following format:
// Employee’s Information:
// ->
// The employee’s full name is: < Employee Name>
// ->
// The employee’s ID number is: < Employee ID>
// ->
// The employee’s current salary is: < Employee salary>
// ->
// Attempt to check if employee’s is eligible for a salary raise
// Apply the raiseSalary() method to the employee’s object
// -->
// Print out the following:
// < Employee’s ID> new salary is < Employee Salary>
-->
}
}

Sample Output

Below is an example of what your output should roughly look like when this lab is completed. Text in green represents user input.

Enter employee's name:
Jack Mann
Enter employee's Id:
123456789
Enter employee's rating:
1
Employee's Information
The employee’s full name is: Jack Mann
The employee’s ID number is: 123456789
The employee’s current salary is: 4000.0
Jack Mann new salary is y is: 4160.0

Enter employee's name:
Bill John
Enter employee's Id:
98762345
Enter employee's rating:
3
Employee's Information
The employee’s full name is: Bill John
The employee’s ID number is: 98762345
The employee’s current salary is: 4000.0
Bill John new salary is y is: 4000.0
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.