1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
postnew [5]
3 years ago
15

Write a Java program that calculates and prints the monthly pay check for an employee. The net pay is calculated after taking th

e 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
Computers and Technology
1 answer:
Anna007 [38]3 years ago
5 0

Answer:

import java.io.FileWriter;

import java.util.Scanner;

public class PayCheck {

public static void main(String[] args) {

 // Create an object of the Scanner class to allow for user's input

 // via the  keyboard.

 Scanner input = new Scanner(System.in);

 // Prompt the user to enter employee's name

 System.out.println("Please enter employee's name");

 // Store the user's input in a String variable called name.

 String name = input.nextLine();

 // Prompt the user to enter the gross amount

 System.out.println("Please enter the gross amount (in dollars)");

 // Store the user's input in a double variable called amount.

 double amount = input.nextDouble();

 // Calculate the Federal Income Tax

 double FIT = 15 / 100.0 * amount;

 // Calculate the State Tax

 double ST = 3.5 / 100.0 * amount;

 // Calculate the Social Security Tax

 double SST = 5.75 / 100.0 * amount;

 // Calculate the Medicare/Medicaid Tax

 double MT = 2.75 / 100.0 * amount;

 // Calculate Pension Plan

 double PP = 5 / 100.0 * amount;

 // Calculate the Health Insurance;

 double HI = 75.00;

 // Calculate total pay to be deducted from actual pay

 double TOTAL = FIT + ST + SST + MT + PP + HI;

 // Calculate the net pay

 double NETPAY = amount - TOTAL;

 // Format the result using String.format() to print out the details of

 // the employee plus the amount paid in two decimal places

 // Store the result of the formatting in a String variable, paydetails.

 String paydetails = String.format("%s%.2f\n", "Gross Amount: $", amount);

 paydetails += String.format("%s%.2f\n", "Federal Tax: $", FIT);

 paydetails += String.format("%s%.2f\n", "State Tax: $", ST);

 paydetails += String.format("%s%.2f\n", "Social Security Tax: $", SST);

 paydetails += String.format("%s%.2f\n", "Medicare/Medicaid Tax: $", MT);

 paydetails += String.format("%s%.2f\n", "Pension Plan: $", PP);

 paydetails += String.format("%s%.2f\n", "Health Insurance: $", HI);

 paydetails += String.format("%s%.2f\n", "Net Pay: $", NETPAY);

 // Print out the result to the console

 System.out.println(paydetails);

 // You could also write the output to a file named document4.txt

 //  using the  FileWriter class.

 try {

  FileWriter fwriter = new FileWriter("document4.txt");

  fwriter.write(paydetails);

  System.out.println("Written to file");

  fwriter.close();

 } catch (Exception e) {

  e.printStackTrace();

 }

}

}

Explanation:

The source code file for this program has also been attached to this response. Please download the source code file for better readability. The code contains comments that explain every segment of the code. Kindly read through the comments line after line.

Hope this helps!

Download java
You might be interested in
Your motherboard has sockets for 184-pin dimm ram. which type of ram should you install?
noname [10]

Answer:

DDR

Explanation:

DDR is the only type of RAM that runs on 184 pins, its successor DDR2 was upgraded to run on 240 pins.

Hope this helps!

4 0
2 years ago
What formula would you enter to add the values in cells b4, b5, and b6?
Semenov [28]
=SUM(b4:b6)  If it doesn't show the $ sign just make sure it's in currency :)  I hope this helped!! Good Luck!!! :)
4 0
3 years ago
Being nice take the points​
MArishka [77]

Answer:

Sure!!! and thank you very much

4 0
3 years ago
[1] Our son has started playing organized T-ball, a beginner’s version of baseball. [2] “Organized” is what parents call it, any
k0ka [10]
I think it is 3 no? Maybe I dunno but I am confident
6 0
3 years ago
Read 2 more answers
Which type of message format is designed to arouse curiosity, not showing the product or delivering quite enough information to
Anarel [89]

The type of message format that is designed to arouse curiosity by not showing the product or delivering quiet enough information to make sense is teaser. This is a way of providing information that is short and in which it does not identify the product or the whole message itself. 

7 0
3 years ago
Other questions:
  • One reason for using social media is to develop social and professional contacts. True or false?
    9·2 answers
  • Suppose the information content of a packet is the bit pattern 1110 0110 1001 1101 and an even parity scheme is being used. What
    15·1 answer
  • Get these points why they hot!!!!!!!!!!!!!!!!!!!!
    14·2 answers
  • Do you need to know javascript to learn python?
    8·1 answer
  • Name the function in Python that prompts user to enter values as per the data type specified.
    5·1 answer
  • Which two statements are true about the Data Sync functionality? (Choose two.)
    15·1 answer
  • Should a waiting thread receive priority over a thread first attempting to enter a monitor? What priority scheme, if any, should
    9·1 answer
  • Once secured a wheelchair may move up to 6 inches in any direction
    6·1 answer
  • ______ is a slow process that takes place in nature. (2 points)
    8·1 answer
  • Calculate the cash available to retire debt for each of the six months. There is cash available to retire debt if there is a cas
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!