Your employer needs a program that calculates and prints the bi-monthly paycheck
ID: 3629808 • Letter: Y
Question
Your employer needs a program that calculates and prints the bi-monthly paycheck for an employee.The net pay is calculated after taking the following deductions;
Federal Income Tax 15%
State Tax 3.5%
Social Security Tax 5.75%
Medicare/Medicaid Tax 2.75%
Pension Plan 5%
Health Insurance $75.00
Your program will read the input, employee name and the gross pay amount from a data file.
The format of the data file is: FirstName LastName AnnualSalary
The program will write the data to a data file in the following format:
firstName LastName grossPay FederalTaxes StateTaxes SSNTaxes Medicare/MedicaidTaxes PensionTax HealthInsurance NetPay
For example:
input file: Allison Neilds 92950.00
output file: Allison Neilds 3872.92 580.94 135.55 222.69 106.51 193.65 75.00 2558.58
FYI: There are 26 pay periods in the year; the salary in the input file is the annual salary (what they get paid each year).
Explanation / Answer
please rate - thanks
I believe your sample output is incorrect 92950/26 is not 3872.92
import java.util.*;
import java.io.*;
public class FileOut
{
public static void main(String[] args)throws IOException, FileNotFoundException
{String filename;
Scanner input=new Scanner(System.in);
System.out.println("Enter the name of your input file: ");
filename=input.next();
Scanner in=new Scanner(new File(filename));
PrintWriter f=new PrintWriter(new FileWriter("output.txt"));
double pay, fed,state,ss,med,pen,health,salary;
String last,first;
first=in.next();
last=in.next();
pay=in.nextDouble();
pay/=26;
fed=pay*.15;
state=pay*.035;
ss=pay*.0575;
med=pay*.0275;
pen=pay*.05;
health=75;
salary=pay-fed-state-ss-med-pen-health;
f.printf("%s %s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f ",first,last,pay,fed,state,ss,med,pen,health,salary);
f.close();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.