Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

PAY RATE 1000 HOURS 4000 OVERTIME 000 GROSS PAY 40000 TAX DEDUCTION 6000 NET PAY 34000 PAY RATE 1200 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability And Statistics

Authors: Morris H. DeGroot, Mark J. Schervish

4th Edition

9579701075, 321500466, 978-0176861117, 176861114, 978-0134995472, 978-0321500465

More Books

Students also viewed these Electrical Engineering questions

Question

What is the biggest strength of the program?

Answered: 1 week ago