Question: Exercise O13 The payroll interface is defined as follows: public interface Payroll { double TAXRATE = 0.15; // tax rate double getGrossPay( ); // to

Exercise O13

The payroll interface is defined as follows:

public interface Payroll

{

double TAXRATE = 0.15; // tax rate

double getGrossPay( ); // to compute and return the gross pay

double getDeductions( ); // to compute and return the deductions

void printDetails( ); // to output the payroll

}

  1. Write the definition of theclass HourlyPay that implements the interfacePayroll as follows:
  • It has two private instance variables hours (double) andpayRate (double).
  • The constructor without parameters initializes the instancevariable hours to 40 and payRate to 10.00
  • It has an additional private instancemethod double getOverTime( ) that does the following: it returns 1.5 *(hours – 40) *payRate if the value of the instancemethod hours is greater than 40; and 0otherwise.
  • Instance method getGrossPay( ) returns hours * payRate + overtime.
  • Instance method getDeduction( ) returns TAXRATE * gross pay.
  • Override the toString method of this classas follows: it uses the String.format( ) static method to create and return the followingstring:

PAYRATE:

HOURS:

OVERTIME:

GROSSPAY:

TAX DEDUCTION:

NETPAY:

  • Public instance method printDetails( ) prints the payroll information above.
  1. Write the definition of the class ExerciseO13 with the method main thatdoes the following:
  • Define an object and initializes it with the defaultconstructor.
  • Call the printDetails( ) method toprint its payroll information.
  • Define an object and initializes it with the hours 50 and payrate $12.
  • Call the printDetails( ) method toprint its payroll information.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

PAY RATE 1000 HOURS 4000 OVERTIME 000 GROSS PAY 40000 TAX DEDUCTION 6000 NET PAY 34000 PAY RATE 1200 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!