Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java, I need to write a program that reads the following information and p

ID: 3926741 • Letter: U

Question

Using Java, I need to write a program that reads the following information and prints a payroll statement:

Employee's name (e.g. Smith)

Number of hours worked in a week (e.g. 10)

Hourly pay rate (e.g. 9.75)

Federal tax withholding rate (e.g. 20%)

State tax withholding rate (e.g. 9%)

Therefore, the output would print

Employee name: Smith

Hours worked: 10

Pay Rate: $9.75

Gross pay: $97.5

Deductions:

   Federal Withholding (20.0%): $19.5

   State Withholding (9.0%): $8.77

   Total deductions: $28.27

Net Pay: $69.22

Explanation / Answer

PayrollTest.java


import java.text.DecimalFormat;
import java.util.Scanner;

public class PayrollTest {

  
   public static void main(String[] args) {
      
       Scanner scan = new Scanner(System.in);
      
       System.out.println("Enter Emplyee Name :");
       String name = scan.nextLine();
       System.out.println("Enter Number of hours worked :");
       int hours = scan.nextInt();
       System.out.println("Enter Pay rate :");
       double rate = scan.nextDouble();
       System.out.println("Enter Federal tax withholding rate :");
       double federalTaxRate = scan.nextDouble();
       System.out.println("Enter State tax withholding rate :");
       double stateTaxRate = scan.nextDouble();
       double gross = hours * rate;
       double federalTax =    (gross * federalTaxRate) /100;  
       double stateTax = (gross * stateTaxRate)/100;
       double netPay = gross - stateTax - federalTax;
       DecimalFormat df = new DecimalFormat("0.00");
       System.out.println("Employee name: "+name);
       System.out.println("Hours worked: "+hours);
       System.out.println("Pay Rate: $"+df.format(rate));
       System.out.println("Gross Pay: $"+df.format(gross));
       System.out.println("Deductions:");
       System.out.println(" Federal Withholding ("+federalTax+"%): $"+df.format(federalTax));
       System.out.println(" State Withholding ("+stateTax+"%): $"+df.format(stateTax));
       System.out.println(" Total deductions: $"+df.format((federalTax+stateTax)));
      
       System.out.println("Net Pay: $"+df.format(netPay));
   }

}

Output:

Enter Emplyee Name :
Smith
Enter Number of hours worked :
10
Enter Pay rate :
9.75
Enter Federal tax withholding rate :
20
Enter State tax withholding rate :
9
Employee name: Smith
Hours worked: 10
Pay Rate: $9.75
Gross Pay: $97.50
Deductions:
   Federal Withholding (19.5%): $19.50
   State Withholding (8.775%): $8.78
   Total deductions: $28.28
Net Pay: $69.22

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote