How do you expand this Payroll program to include a function for public assistan
ID: 3802398 • Letter: H
Question
How do you expand this Payroll program to include a function for
public assistance fund.
The program should allocate constants with final data type for tax rates to include:
(1) local rate: 5%
(2) state rate: 2.5%
(3) federal rate: 10%
(4) medical insurance: 2%
(5) unemployment insurance: 2.5%
(6) social security contribution: 5%
4. The program accepts these data from keyboard:
(1) employee first and last name in string format
(2) social security number in string type variable format as: xxx-xx-xxxx
(3) salary period in string format: Month & Year (i.e February,2017)
(3) monthly income in integer
5. Calculate total tax amount, minus from annual income for net salary payment
and O/P the calculated results in this format with one console O/P statement:
Monthly Payroll Salary Payment Check
==========================================
Employee Name: xxxxxxxx xxxxxxxxx
SSN: xxx-xx-xxxx
salary period: Month & Year (i.e February,2017)
gross payment: xxxxx
deductions:
(1) local tax: xxx.xx
(2) state tax: xxx.xx
(3) federal tax: xxx.xx
(4) medical insurance: xxx.xx
(5) unemployment insurance: xxx.xx
(6) social security contribution: xxx.xx
Total deduction: xxxx.xx
Net payment: xxxx.xx
End of Job
*/
Explanation / Answer
package org.students;
import java.util.Scanner;
public class MonthlyPayrollSalaryPaymentCheck {
public static void main(String[] args) {
//Declaring variables
String fname,lname,SSN,salary_period;
int monthly_income;
double localr,stater,federalr,medicalI,unemployement,ssc;
double total_tax,net_salary;
//Declaring constants
final double LOCALRATE=0.05;
final double STATERATE=0.025;
final double FEDERALRATE=0.10;
final double MEDICALINSURANCE=0.02;
final double UNEMPLOYEMENT_INSURANCE=0.025;
final double SOCIAL_SECURITY_CONTRIBUTION=0.05;
//Scanner object is used to get the inputs entered by the user
Scanner sc=new Scanner(System.in);
//Getting the employee details
System.out.print("Enter Employee FirstName :");
fname=sc.next();
System.out.print("Enter Employee LastName :");
lname=sc.next();
System.out.print("Enter SSN :");
SSN=sc.next();
System.out.print("Enter Salary Period :");
salary_period=sc.next();
System.out.print("Enter monthly income :");
monthly_income=sc.nextInt();
//calculating tax deductions
localr=monthly_income*LOCALRATE;
stater=monthly_income*STATERATE;
federalr=monthly_income*FEDERALRATE;
medicalI=monthly_income*MEDICALINSURANCE;
unemployement=monthly_income*UNEMPLOYEMENT_INSURANCE;
ssc=monthly_income*SOCIAL_SECURITY_CONTRIBUTION;
total_tax=localr+stater+federalr+medicalI+unemployement+ssc;
net_salary=monthly_income-total_tax;
//Displaying the result
System.out.println(" Monthly Payroll Salary Payment Check");
System.out.println("==========================================");
System.out.println("Employee Name: "+fname+" "+lname);
System.out.println("SSN: "+ssc);
System.out.println("salary period: "+salary_period);
System.out.println("gross payment:"+monthly_income);
System.out.println("deductions:");
System.out.println("(1) local tax: "+localr);
System.out.println("(2) state tax: "+stater);
System.out.println("(3) federal tax: "+federalr);
System.out.println("(4) medical insurance: "+medicalI);
System.out.println("(5) unemployment insurance: "+unemployement);
System.out.println("(6) social security contribution: "+ssc);
System.out.println("Total deduction: "+total_tax);
System.out.println("Net payment: "+net_salary);
}
}
______________________
Output:
Enter Employee FirstName :Kane
Enter Employee LastName :Williams
Enter SSN :123-45-6789
Enter Salary Period :February,2017
Enter monthly income :90000
Monthly Payroll Salary Payment Check
==========================================
Employee Name: Kane Williams
SSN: 4500.0
salary period: February,2017
gross payment:90000
deductions:
(1) local tax: 4500.0
(2) state tax: 2250.0
(3) federal tax: 9000.0
(4) medical insurance: 1800.0
(5) unemployment insurance: 2250.0
(6) social security contribution: 4500.0
Total deduction: 24300.0
Net payment: 65700.0
_______________Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.