Answer to Question #282180 in Java | JSP | JSF for bbhhjjf

Question #282180

A member class has id, name and payment rate. In member class make abstract method: calculateSalary(): that calculates Salary of each member in arraylist. Write another class ContractMember that extends Member

a. Provide a data member contractStart and contractEnd (LocalDateTime) 

b. Provide a static constant TAXRATE and initialize it to 0.07

d. Override the method calculateSalary which calculates the salary by finding the number of days between the start and end of the contract and callculating the salary for these days @ of the rate defined earlier. The method then deducts tax from this amount @ the TAXRATE and returns the net payable amount as salary.

Build a class AdHocMember which extends the ContractMember

a. Add an instance variable status (booelan).

b.Provide getter,setter and appropriate constructor. The status of an AdHocMember is true by default

c.Override the calcualteSalary method so that it calculates the salary as done in the ContractEmployee if the status is true and returns 0 otherwise. 


1
Expert's answer
2021-12-23T00:29:30-0500
public abstract class Member {
    private int id;
    private String name;
    private double paymentRate;

    public abstract double calculateSalary();

    public double getPaymentRate() {
        return paymentRate;
    }
}


import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class ContractMember extends Member {
    public static final double TAXRATE = 0.07;
    private LocalDateTime contractStart;
    private LocalDateTime contractEnd;

    @Override
    public double calculateSalary() {
        return Duration.between(contractStart, contractEnd).get(ChronoUnit.DAYS) * getPaymentRate() * (1 - TAXRATE);
    }
}


public class AdHocMember extends ContractMember {
    private boolean status;

    public AdHocMember() {
        status = true;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public boolean status() {
        return status;
    }

    @Override
    public double calculateSalary() {
        return status ? super.calculateSalary() : 0;
    }
}

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