Answer to Question #298925 in Java | JSP | JSF for rim

Question #298925

Compose an Employee class with the attributes personalia(data type Person),

employeeNo, yearofAppointment, monthSalary, and taxPercent. In addition to get

methods for all the attributes, the following operations should be available :

a. Find the employee’s monthly tax.

b. Find the gross annual salary

c. Find tax savings per year. To our employees June is tax free, and in

December there’s only half the usual tax.

d. Find name (in the format last name, first name.)

e. Find age

f. Find number of years employed at the company.

g. Find out if the person has been employed for more than a given number of

years (parameter)

h. Set methods to change attributes that it makes sense to change.

i. Find out in which cases an instance of the Employee class has to

collaborate with its personalia object in order to complete these tasks.


Write a simple program that puts data into an instance of the Employee class and calls all

the methods you’ve created. Check that the results are correct


1
Expert's answer
2022-02-17T14:49:56-0500
import java.time.LocalDate;

public class Employee {
    private Person personalia;
    private int employeeNo;
    private int yearOfAppointment;
    private double monthlySalary;
    private double taxPercent;

    public double monthlyTax() {
        return monthlySalary * taxPercent;
    }

    public double grossSalary() {
        return monthlySalary * 12;
    }

    public double taxSavingsPerYear() {
        return monthlyTax() * 10 + monthlyTax() / 2;
    }

    public String getName() {
        personalia.getLastName + " " + personalia.getFirstName();
    }

    public int getAge() {
        return personalia.getAge();
    }

    public int getYearsAtCompany() {
        return yearOfAppointment - LocalDate.now().getYear();
    }

    public boolean isWorksLongerThan(int years) {
        return getYearsAtCompany() > years;
    }

    public Person getPersonalia() {
        return personalia;
    }

    public void setPersonalia(Person personalia) {
        this.personalia = personalia;
    }

    public int getEmployeeNo() {
        return employeeNo;
    }

    public void setEmployeeNo(int employeeNo) {
        this.employeeNo = employeeNo;
    }

    public int getYearOfAppointment() {
        return yearOfAppointment;
    }

    public void setYearOfAppointment(int yearOfAppointment) {
        this.yearOfAppointment = yearOfAppointment;
    }

    public double getMonthlySalary() {
        return monthlySalary;
    }

    public void setMonthlySalary(double monthlySalary) {
        this.monthlySalary = monthlySalary;
    }

    public double getTaxPercent() {
        return taxPercent;
    }

    public void setTaxPercent(double taxPercent) {
        this.taxPercent = taxPercent;
    }
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS