QuestionQuestion

- Design and implement a class Employee in a java file called Employee.java. The class should contain private instance variables for employee id, age, yearsOfService.
- Define the Employee constructor with three parameters to accept and initialize instance data. The class should also keep track of the number of employee objects created using a static variable. This variable gets incremented every time in the constructor.
- Include get and set methods for the three instance variables.
- Include an instance method called isEligibleForRetirement() that returns a boolean, returns true if the employee is eligible for retirement, false if not.
- For an employee to be eligible for retirement, the sum of age and years of service needs to be greater than 60.
- Create a client class called EmployeeApp (in a file called EmployeeApp.java) which has a main method.
- Using Scanner class, it will ask the user for data for 2 employees, i.e. id, age, and years of service for emp 1 and then emp 2.
- Take this user input and invoke the constructor of Employee class, passing the user provided input as arguments. You now have 2 initialized Employee instances.
- Now, your main method should print the number of Employee objects created, display data for each, and specify whether each employee is eligible for retirement or not.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Employee {
    private int employeeId;
    private int age;
    private int yearsOfService;

    private static int numberOfEmployee = 0;
    public Employee(int employeeId, int age, int yearsOfService) {
       this.employeeId = employeeId;
       this.age = age;
       this.yearsOfService = yearsOfService;
       numberOfEmployee++;
    }
   
    public void setAge(int age) {
       this.age = age;
    }

    public void setEmployeeId(int employeeId) {
       this.employeeId = employeeId;
    }...
$15.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats