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]
4 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]4 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
What ethical concerns might arise from applying new IT to law enforcement?
pentagon [3]

Answer:

One ethical concern that might occur is the rise of bias in the police department. It would be possible for a disgruntled or frustrated cop to lean into new IT and be able to take advantage of a past suspect or an "enemy" of theirs such as a neighbor or even a coworker.

6 0
3 years ago
Why is art important to heritage?
Sophie [7]
<span>but of culture, values and traditions. Cultura</span>
7 0
3 years ago
What is the best example of how computers have changed the way people communicate?
azamat

Answer:

c since it is very important that people reached where ever they are

Hope This Helps!!!

4 0
2 years ago
Where should fire extinguishers be stored on a boat?
fomenos

<span>Fire extinguishers should be stored in a boat at the engine area and near the operator. A fire extinguisher should be put near the engine because the engine of the boat is a fire hazardous place and this is the area where a fire could start.  The fire extinguisher should be installed properly using a mounting bracket to hold the extinguisher in place. There are different types of extinguishers that should be installed in the boat, these are type A, B, and C extinguishers. Type A extinguishers can turn off the fire caused by combustible solids like wood and paper. Type B extinguishers can turn off fire caused by gasolines, oil, and greases. While Type C extinguishers can turn off fire caused by an electrical problem.</span>

5 0
3 years ago
2. cien-si-mu-ne ..............​
sammy [17]

Answer:

henghour669, what the heck is this saying

Explanation:

5 0
4 years ago
Other questions:
  • Why will the standard replacement algorithms (LRU, FIFO, clock) not be effective in handling this workload for a page allocation
    11·1 answer
  • The general manager for a retail clothing outlet was recently cited as saying, IT is the cornerstone of our company. All of our
    9·1 answer
  • How does this app work?
    11·2 answers
  • )the number of levels in a tree is called
    6·1 answer
  • What are the benefits of transferable skills check all the boxes that apply
    6·2 answers
  • A typical day in programming and software development would involve
    12·1 answer
  • Use the drop-down menus to answer questions about the options in the Window group. Which command allows a user to view presentat
    6·2 answers
  • What online server provides you space to store and launch your website?
    11·1 answer
  • Priortization is an example of a skill that helps you reach long term goals because
    14·1 answer
  • What is it called when a programmer includes a step in an algorithm that lets
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!