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 a critique of the feature detector model of object recognition?​?
Leya [2.2K]
Found a similar question that had choices, here are the choices:
a.Specific neurons that respond to round, square or irregular shapes do not integrate their signals to recognize multi-shaped objects.
b. It accounts only for the recognition of simple two dimensional shapes, not more complex three-dimensional shapes.
c.Feature detector neurons have been found in non-human primates, but not in humans themselves.
<span>d. It does not account for the fact that our expectations influence what we see.

My answer:
d. It does not account for the fact that our expectations influence what we see.

We all have different expectations, thus, our view on certain object is subjective. It is a product of said expectations. </span>
4 0
3 years ago
Question 4 of 25
Semmy [17]

A situation which modular design would be least beneficial for a game program is: A. the program is extremely simple.

<h3>What is modular design?</h3>

Modular design can be defined as a software development technique that involves the separation of the overall functionality of a software into independent and interchangeable software sections or modules.

Also, modular design can be used to break a large code in a software into smaller blocks holding specific functions.

In this context, we can infer that modular design would be least beneficial for a game program when the software program is extremely simple.

Read more on modular design here: brainly.com/question/14192464

#SPJ1

6 0
2 years ago
You have a server called server1 that is running windows server 2012. what command would you use to delete the ptr record for 10
dybincka [34]
You could use th dnscmd server1 /recorddelete command that would allow you to delete record through powershell
3 0
3 years ago
How bridges are built over water
Black_prince [1.1K]
It’s all depending on what method
4 0
2 years ago
Use the code below to answer the following questions. Note that the catch statements in the code are not implemented, but you wi
anzhelika [568]

Answer:

d) either e1 or e5

Explanation:

Here, the instruction i1 goes ahead in trying to open the given file through an input stream buffer reader. If the given file name is wrong, it will indicate that an e1 file is not found or if any other IO errors due to invalid stream, no disc in drive e5 IO exception will be drawn.

4 0
3 years ago
Other questions:
  • Put the following five steps in the order in which you would perform them to use the Paste Special function: ____. 1. Select and
    5·1 answer
  • _______ refers to the poitically, religiously, or ideologically motivated use of computers (or related technology) by an individ
    15·1 answer
  • Pinterest, a visual bookmarking Website, logs more than 14 terabytes of new data each day, which means its storage needs are con
    10·1 answer
  • How many hosts are in each subnet?
    15·1 answer
  • What is the main feature of Ethernet over Power?
    9·1 answer
  • Write a C++ program to find if a given array of integers is sorted in a descending order. The program should print "SORTED" if t
    14·1 answer
  • Which of the following is not a command for determining if MySQL is running on Linux (Ubuntu)?
    7·1 answer
  • You have a technical interview for a new position in digital media. One of the questions you are asked is this: “A client asks y
    13·1 answer
  • Describe psychographic differences among the past five generations of Americans that you learned about in this course. What type
    6·1 answer
  • 4. Ernesto works in a small office with five other people. What are two possible connection
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!