Employee Class - Java Programming - Semester 1 Assignment - Solution

Verified

Added on  2019/10/16

|2
|292
|253
Homework Assignment
AI Summary
This assignment involves creating an Employee class in Java. The solution includes defining instance variables for the employee's name, attendance rate, and hours worked. It also involves creating a constructor to initialize these variables and a static variable to track the number of employee objects created. The assignment requires implementing get and set methods for the instance variables, and an instance method called isEligibleForBonus() that returns a boolean value based on the product of attendance rate and hours worked. This solution provides a practical example of object-oriented programming concepts in Java, focusing on class structure, instance variables, methods, and conditional logic.
Document Page
public class Employee {
//To-Do: Declare three instance variables:
//1) employee’s name (string),
//2) attendanceRate (double),
//3) hoursWorked (integer).
//To-Do: Declare a static variable for tracking the number of employee objects created
// -----------------------------------------------------------------
// A constructor
// -----------------------------------------------------------------
public Employee(String newName, double newAR, int newHours) {
//To-Do: use newName, newAR, newHours to initialize instance data
//To-Do: increase the value of the static variable for tracking the number of employee objects
created
}
//To-Do: Include get and set methods for the three instance variables.
//For example, this is a set method for an employee’s name
//public void setName(String input_name){
// name = input_name;
//}
//And, this is an example get method for employee's name
// public String getName(){
// return name;
// }
// This is an instance method called isEligibleForBonus() that returns a boolean.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
public boolean isEligibleForBonus(){
//To-Do:
// return true if the employee is eligible for bonus, false if not.
// For an employee to be eligible for bonus, the multiplication of attendanceRate and
hoursWorked needs to be greater than 36
}
}
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]