Exercise O13 The payroll interface is defined as follows: public interface Payroll { double TAXRATE = 0.15;
Fantastic news! We've Found the answer you've been seeking!
Question:
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
}
- 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.
- 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.
Related Book For
Probability And Statistics
ISBN: 9780321500465
4th Edition
Authors: Morris H. DeGroot, Mark J. Schervish
Posted Date: