Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, you are required to complete it using a User-defined class.

ID: 3530902 • Letter: F

Question

For this assignment, you are required to complete it using a User-defined class. An employee is paid at a rate of $23.67 per hour for regular hours worked in a week. From the worker's gross pay, 12.18% is withheld for federal income tax, 1.45% is withheld for medicare, 4.2% is withheld for Social Security, 3.55% for NYS income tax, 2.28% for NYC income tax, and $10 per week is withheld for union dues. Create a solution that will read in the number of hours worked in a week and then output the worker's gross pay, each withholding amount, and the net take-home pay for the week. Please utilize all the material we covered so far. For example, constant variables, formatting output, etc.

Explanation / Answer


public class Employee {
public static final double PAY_RATE = 23.67;
public static final double INCOME_TAX = 12.18;
public static final double MEDICARE =4.2;
public static final double SOCIAL_SECURE = 3.55;

public static final double NYS_INCOME_TAX = 2.28;
public static final double UNION_DUES =10 ;


public void computeDisplayGrossPay(int hours) {
double grossPay = PAY_RATE * hours;
double incomeTax = grossPay * INCOME_TAX/100;
double medicare = grossPay * MEDICARE /100;
double ssecure = grossPay *SOCIAL_SECURE /100;
double nysTax = grossPay * NYS_INCOME_TAX /100;
double netPay = grossPay - ( incomeTax+medicare + ssecure + nysTax );
netPay = grossPay - UNION_DUES;
System.out.println("Gross Pay is :" + grossPay);
System.out.println("incomeTax is :" + incomeTax);
System.out.println("medicare is :" + medicare);
System.out.println("social secure is :" + ssecure);
System.out.println("nysTax is :" + nysTax);

System.out.println("Net Pay is :" + netPay);
}
}



public class PaymentTest {


public static void main(String[] args) {

Employee e = new Employee();
e.computeDisplayGrossPay(43);

}

}


Output:


Gross Pay is :1017.8100000000001
incomeTax is :123.96925800000001
medicare is :42.748020000000004
social secure is :36.132255
nysTax is :23.206068000000002
Net Pay is :1007.8100000000001


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote