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

Need help with the following codes: public interface Payable { double getPayment

ID: 3541666 • Letter: N

Question

Need help with the following codes:



public interface Payable

{

          double getPaymentAmount();  //calculate payment; no implementation
}  //end interface



public abstract class Employee implements Payable
{
   private String firstName;
   private String lastName;
   private String socialSecurityNumber;

   // three-argument constructor
   public Employee( String first, String last, String ssn )
   {
      firstName = first;
      lastName = last;
      socialSecurityNumber = ssn;
   } // end three-argument Employee constructor

   // set first name
   public void setFirstName( String first )
   {
      firstName = first; // should validate
   } // end method setFirstName

   // return first name
   public String getFirstName()
   {
      return firstName;
   } // end method getFirstName

   // set last name
   public void setLastName( String last )
   {
      lastName = last; // should validate
   } // end method setLastName

   // return last name
   public String getLastName()
   {
      return lastName;
   } // end method getLastName

   // set social security number
   public void setSocialSecurityNumber( String ssn )
   {
      socialSecurityNumber = ssn; // should validate
   } // end method setSocialSecurityNumber

   // return social security number
   public String getSocialSecurityNumber()
   {
      return socialSecurityNumber;
   } // end method getSocialSecurityNumber

   // return String representation of Employee object
   @Override
   public String toString()
   {
      return String.format( "%s %s social security number: %s",
         getFirstName(), getLastName(), getSocialSecurityNumber() );
   } // end method toString
   
   // abstract method overridden by concrete subclasses
   public abstract double earnings(); // no implementation here
   
   @Override
    double getPaymentAmount()
   {
       earnings();
       return earnings();
   }  //calculate payment; no implementation

   // Note: We do not implement Payable method getPaymentAmount here so  
   // this class must be declared abstract to avoid a compilation error.
} // end abstract class Employee



I got this error message:


getPaymentAmount() in Employee cannot implement getPaymentAmount() in Payable
  attempting to assign weaker access privileges; was public

Explanation / Answer

Just add "public" keyword before double getPaymentAmount(). so the new line becomes:

public double getPaymentAmount()


and it will not give any error.


Updated Code can be found at:

Employee.java: https://dl.dropboxusercontent.com/u/42883368/chegg/CheggNetbeans/src/Employee.java

Payable.java: https://dl.dropboxusercontent.com/u/42883368/chegg/CheggNetbeans/src/Payable.java

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