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
}
- 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
PAY RATE 1000 HOURS 4000 OVERTIME 000 GROSS PAY 40000 TAX DEDUCTION 6000 NET PAY 34000 PAY RATE 1200 ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started