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
what is the command used to retrieve the java files along with the string existence "Hello world" in it​
Leona [35]

Answer:

java” xargs grep -i "Hello World”

8 0
3 years ago
External network security threats can include management failure to support organization-wide security awareness, inadequate sec
stiks02 [169]

Answer:

B. False

Explanation:

External security threat can be defined as any threats coming outside the company's computer network operation, usually carried out with negative or hostile intent for the purpose of stealing information or distracting the flow of operation. For example, Virus Attack

However, given that the question talked about the "management failure to support organization-wide security awareness, inadequate security policies, and unenforced security procedures."

Hence, this is not an External Security Threat, which means, the correct answer is FALSE.

5 0
3 years ago
Frames control what displays on the Stage, while keyframes help to set up
pogonyaev

Answer: A keyframe is a location on a timeline which marks the beginning or end of a transition. So for example, you have a movie and it transitions to another scene, keyframes tell it when and where to start the transition then when and where to stop the transition.

3 0
3 years ago
What term refers to a celebrity or other popular figure publicly supporting a product?
IgorLugansk [536]

Answer:

Endorsement

Explanation:

The term that refers to this is known as an Endorsement. This can be for any product or service and generally involves a celebrity or public figure that in one way or another relates to the product or service being advertised. One example of this would be famous soccer icon Christiano Ronaldo publicly supporting and appearing in Nike advertisements showing off their new soccer cleats.

3 0
3 years ago
Businesses that conduct telemarketing are required to access the Do-Not-Call Registry every _______ in order to maintain an upda
densk [106]

Businesses that conduct telemarketing are required to access the Do-Not-Call Registry every 31 days in order to maintain an updated database of people.

<h3>What telemarketing firms do?</h3>

The act of telemarketing is known to be the act talking to potential or existing customers through the use of a telephone.

Conclusively, Note that Telemarketing can help a business firm to promote or boast their products or services, make their customer database stronger, bring about a lot of leads and appointments and others.

Learn more about telemarketing from

brainly.com/question/25974538

6 0
2 years ago
Other questions:
  • A windows host sends a tcp segment with source port number 1200 and destination port number 25. the sending host is a(n) _______
    10·1 answer
  • Current versions of windows support file names up to ________ characters long
    5·1 answer
  • You are going to write a program for Computer test which will read 10 questions from a file, order them randomly and provide the
    11·1 answer
  • What conversion factor should be used to convert from meters to Gigameters?
    7·1 answer
  • The following types of websites are
    10·1 answer
  • If you're unsure of what chart to use for a set of data, what feature does Excel include that will help you to decide?
    7·1 answer
  • Write a SELECT statement that uses an aggregate window function to get the total amount of each order. Return these columns: The
    13·1 answer
  • What is the largest value that can be represented by 6 binary digits? .
    5·1 answer
  • What is the ghosted text or picture behind the content on the page?​
    6·1 answer
  • Please hurry!
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!