View the step-by-step solution to:

Question

Specify, design, and implement a class called PayCalculator. The class should have at least the following

instance variables:

·        employee's name

·        reportID: this should be unique. The first reportID must have a value of 1000 and for each new reportID you should increment by 10.

·        hourly wage

Include a suitable collection of constructors, mutator methods, accessor methods, and toString method. Also, add methods to perform the following tasks:

1.     Compute yearly salary - both the gross pay and net pay

2.     Increase the salary by a certain percentage

3.     Compute pay check net pay for a given pay period (there are 26 pay periods per year). Here is what you have to consider when computing the net pay:

a.     Federal Tax deductions - 9%

b.     State Tax deductions - 2%

c.      Overtime - number of hours worked over the 80hrs full time load. Here is how you can calculate the overtime pay rate

overTimePay = regularPayRate * 1.5

4.     Compute pay check net pay for all pay periods (all 26 pay periods)


I have added all the constants that you might need in the Constants.java interface. Make sure to include it in your project.




using this constants:


public interface Constants {

public final int[] HOURS_WORKED = {89, 80, 19, 73, 44, 99, 77, 0, 80, 70, 80, 87, 84, 82,

80, 30, 89, 90, 100, 120, 0, 69, 99, 91, 83, 80};

public final int PAY_PERIODS_IN_YEAR = 26;

public final double FEDERAL_TAX_RATE = 0.2;

public final double STATE_TAX_RATE = 0.09;

public final double OVERTIME_RATE = 1.5;

public final double FULL_TIME = 80;

public final int PAY_PERIOD_1 = 0;

public final int PAY_PERIOD_2 = 1;

public final int PAY_PERIOD_3 = 2;

public final int PAY_PERIOD_4 = 3;

public final int PAY_PERIOD_5 = 4;

public final int PAY_PERIOD_6 = 5;

public final int PAY_PERIOD_7 = 6;

public final int PAY_PERIOD_8 = 7;

public final int PAY_PERIOD_9 = 8;

public final int PAY_PERIOD_10 = 9;

public final int PAY_PERIOD_11 = 10;

public final int PAY_PERIOD_12 = 11;

public final int PAY_PERIOD_13 = 12;

public final int PAY_PERIOD_14 = 13;

public final int PAY_PERIOD_15 = 14;

public final int PAY_PERIOD_16 = 15;

public final int PAY_PERIOD_17 = 16;

public final int PAY_PERIOD_18 = 17;

public final int PAY_PERIOD_19 = 18;

public final int PAY_PERIOD_20 = 19;

public final int PAY_PERIOD_21 = 20;

public final int PAY_PERIOD_22 = 21;

public final int PAY_PERIOD_23 = 22;

public final int PAY_PERIOD_24 = 23;

public final int PAY_PERIOD_25 = 24;

public final int PAY_PERIOD_26 = 25;

}


With this Paycalc.test



class PayCalculatorTest {

private PayCalculator payCalculator = new PayCalculator("John", 14.75);

@Test

void testPayCalculator() {

­­­­­­­

}


@Test

void testIncreaseHourlyWage() {

double raiseRate = 10;

double currentWage = payCalculator.getHourlyWage();

double exceptedWage = currentWage * 1.1;

payCalculator.increaseHourlyWage(raiseRate);

double actualWage = payCalculator.getHourlyWage();

assertEquals(exceptedWage, actualWage);

}


@Test

void testGetReportId() {

PayCalculator payCalculator2 = new PayCalculator("Sarah", 35.00);

double reportId1 = payCalculator.getReportId();

double reportId2 = payCalculator2.getReportId();

double actual = reportId2 - reportId1;

assertEquals(10, actual);

}


@Test

void testGetHourlyWage() {

double actualWage = payCalculator.getHourlyWage();

assertEquals(14.75, actualWage);

}


@Test

void testSetHourlyWage() {

payCalculator.setHourlyWage(20.75);

double actualHourlyWage = payCalculator.getHourlyWage();

assertEquals(20.75, actualHourlyWage);

}


@Test

void testPayCheckStub() {

fail("Not yet implemented");

}


@Test

void testOverTimeHoursWorked() {

double hoursWorked = 99;

double actualOverTimeHoursWorked = payCalculator.overTimeHoursWorked(hoursWorked);

assertEquals(19, actualOverTimeHoursWorked);

}


@Test

void testOverTimePay() {

double overTimeHours = 12;

double actualOverTimePay = payCalculator.overTimePay(overTimeHours);

double expected = 265.5;

assertEquals(expected, actualOverTimePay);

}


@Test

void testTotalDeductions() {

double hoursWorked = 120;

double grossPay = payCalculator.grossPay(hoursWorked);

double federalDeductions = payCalculator.federalDeductions(grossPay);

double stateDeductions = payCalculator.stateDeductions(grossPay);

double actualTotalDeduc = payCalculator.totalDeductions(federalDeductions, stateDeductions);

double expectedTotlaDeduc = 598.85;

assertEquals(expectedTotlaDeduc, actualTotalDeduc, 0.01);

}

@Test

void testNetYearIncome() {

int[] hoursPerPayPeriod = {89, 80, 19, 73, 44, 99, 77, 0, 80, 70, 80, 87, 84, 82,

80, 30, 89, 90, 100, 120, 0, 69, 99, 91, 83, 80};

double actualNetYearPay = payCalculator.netYearIncome(hoursPerPayPeriod);

double expected = 20646.53;

assertEquals(expected, actualNetYearPay, 0.01);

}

@Test

void testGrossYearIncome() {

int[] hoursPerPayPeriod = {89, 80, 19, 73, 44, 99, 77, 0, 80, 70, 80, 87, 84, 82,

80, 30, 89, 90, 100, 120, 0, 69, 99, 91, 83, 80};

double actualGrossYearPay = payCalculator.grossYearIncome(hoursPerPayPeriod);

double expected = 29079.62;

assertEquals(expected, actualGrossYearPay, 0.01);

}

@Test

void testNetPay() {

double hoursWorked = 89;

double actual = payCalculator.netPay(hoursWorked);

double expected = 979.18;

assertEquals(expected, actual, 0.01);

}

@Test 

void testGrossPay() {

double hoursWorked = 19;

double actual = payCalculator.grossPay(hoursWorked);

double expected = 280.25;

assertEquals(expected, actual, 0.01);

}

@Test

void testFederalDeductions() {

double hoursWorked = 69;

double grossPay = payCalculator.grossPay(hoursWorked);

double actualFederalDeductions = payCalculator.federalDeductions(grossPay);

double expected = 203.55;

assertEquals(expected, actualFederalDeductions, 0.01);

}

@Test

void testStateDeductions() {

double hoursWorked = 120;

double grossPay = payCalculator.grossPay(hoursWorked);

double actualStateDeductions = payCalculator.stateDeductions(grossPay);

double expected = 185.85;

assertEquals(expected, actualStateDeductions, 0.01);

}


}




Please answer using java!!

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes