Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PayCalculator. Java code needed. There are no specifics, this is for personal us

ID: 3560095 • Letter: P

Question

PayCalculator. Java code needed. There are no specifics, this is for personal use.

Create an abstract class PayCalculator that has an attribute payRate given in dollars per hour. The class should also have a method computePay(hours) that returns the pay for a given amount of time.

Derive a class RegularPay from PayCalculator, as described above. It should have a constructor that has a parameter for the pay rate. It should not override any of the methods. Then derive a class HazardPay from PayCalculator that overrides the computePay method. The new method should return the amount returned by the base class method multiplied by 1.5.

Explanation / Answer

public abstract class PayCalculator
{
public int payRate;
public int computePay(int hours)
{
   return hours*payRate;
}
}

public class RegularPay extends PayCalculator
{
  
   public RegularPay(int val)
{
   payRate = val;
   }
}

public class HazardPay
{

   public int computePay(int hours)
   {
       return hours*payRate*1.5;
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote