Create an abstract class PayCalculator that has an attribute payRate given in do
ID: 3776902 • Letter: C
Question
Create an abstract class PayCalculator that has an attribute payRate given in dollars per hour.
It should have a constructor that has a parameter for the pay rate.
The class should have a method computePay(double hours) that returns the pay for a given amount of time.
It should have an accessor method to return the pay rate.
The class should also have an abstract method getBenefitAmount() that is intended to return a dollar amount representing the amount of money received in benefits over the pay period.
Explanation / Answer
PayCalculator.java
public abstract class PayCalculator {
private double payRate;
public PayCalculator(double payRate){
this.payRate = payRate;
}
public double getPayRate() {
return payRate;
}
public double computePay(double hours){
return hours * payRate;
}
public abstract double getBenefitAmount();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.