Write a Java program that calculates and prints the monthly pay check for an emp
ID: 3626315 • Letter: W
Question
Write a Java program that calculates and prints the monthly pay check 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 should prompt the user to input the employee name and the gross amount. The out put will be stored in a file. Format your output to two decimal places. A sample output follows.
Allison Nields
Gross Amount: $3575.00
Federal Tax: $536.25
State Tax: $125.13
Social Security Tax: $205.56
Medicare/Medicaid Tax: $98.31
Pension Plan: $178.75
Health Insurance: $75.00
Net Pay: $2356.00
Explanation / Answer
import java.io.*;
import java.text.NumberFormat;
import java.util.*;
public class Paychecks {
public static void main(String[] args) throws Exception {
String filename = "Paycheck.txt";
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(new FileWriter(filename));
System.out.print("Enter employee name: ");
out.println(sc.nextLine());
System.out.print("Enter gross amount: ");
double amount = sc.nextDouble();
NumberFormat f = NumberFormat.getCurrencyInstance();
out.println("Gross Amount: "+f.format(amount));
double fedTax = 0.15*amount;
out.println("Federal Tax: "+f.format(fedTax));
double stateTax = 0.035*amount;
out.println("State Tax: "+f.format(stateTax));
double ssTax = 0.0575*amount;
out.println("Social Security Tax: "+f.format(ssTax));
double mediTax = 0.0275*amount;
out.println("Medicare/Medicaid Tax: "+f.format(mediTax));
double pension = 0.05*amount;
out.println("Pension Plan: "+f.format(pension));
double healthInsurance = 75;
out.println("Health Insurance: "+f.format(healthInsurance));
double net = amount-fedTax-stateTax-ssTax-mediTax-pension-healthInsurance;
out.println("Net Pay: "+f.format(net));
out.close();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.