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

A company wants a program that will calculate the basic pay information for all

ID: 3761591 • Letter: A

Question

A company wants a program that will calculate the basic pay information for all of their employees. The following requirements are necessary to make the program work as it needs to:

This program must allow the user to input whether he or she is hourly or salaried.

If salaried, the employee should be prompted to enter a weekly salary.

If hourly, the employee should be prompted to enter an hourly wage and the number of hours worked, so that the program can calculate their weekly pay, including overtime if it is appropriate.

The following taxes must be deducted from gross pay regardless of salary or hourly choice:

State tax of 6%

Federal tax of 15%

Social Security tax of 6.2%

Medicare tax of 1.45%

Output the following in an easily readable format:

Salary or Hourly choice

Either Salary or Hours Worked and Hourly Wage

Total Gross Pay

Each Tax Amount

Net Pay

Your project manager wants a flowchart of your process and detailed comments of your code so that your program is easy to understand for other programmers

Explanation / Answer

/**The java program that prompts user to ener type of employee
* hourly or salaried.
* Prompt wage and number of hours for hourly employee.
* Prompt weekly salary for salaried employee.
* Print state, federal, seccurity and medicare tax
* for the corresponding selected employee
* */
import java.util.Scanner;
public class EmployeePay
{
   public static void main(String[] args)
   {  
       //create scanner class object
       Scanner scanner=new Scanner(System.in);
       //constants variables for taxes
       final double STATE_TAX=0.06; // 6%
       final double FEDERAL_TAX=0.15;//15%
       final double SOCAIL_SECURITY_TAX=0.062;//6.2%
       final double MEDICARE_TAX=0.0145;//1.42%
      
      
       //set variables to zero
       double payRate=0;
       int numHours=0;
       double totalSalary=0;
      
       System.out.println(" 1.Hourly Pay");
       System.out.println(" 2.Salaried Pay");
       System.out.println("Enter your choice : ");
       //read user choice
       int choice=scanner.nextInt();
      
       if(choice==1)
       {
           System.out.println("Enter hourly wage");
           //read hourly wage
           payRate=scanner.nextDouble();
           System.out.println("Enter number of hours workd");
           //read number of hours
           numHours=scanner.nextInt();
           //calculate total salary
           totalSalary=payRate*numHours;
           //print gross pay
           System.out.printf("Gross Pay : %.2f ",totalSalary);
           System.out.printf("Hourly Employee ");
       }
       else if(choice==2)
       {
           System.out.println("Enter weekly pay");
           double weeklySalary=scanner.nextDouble();
           //read weekly salary
           totalSalary=weeklySalary;
           //print gross pay of weekly salary
           System.out.printf("Gross Pay : %.2f ",totalSalary);          
           System.out.println("Weekly Employee");
       }
              
      
      
       //calculate state tax
       double stateTax=totalSalary*STATE_TAX;
       System.out.printf("State Tax :%.2f ",stateTax);
      
       totalSalary=totalSalary-stateTax;
      
       //calculate federal tax
       double federalTax=totalSalary*FEDERAL_TAX;
       System.out.printf("Federal Tax :%.2f ",federalTax);
      
       totalSalary=totalSalary-federalTax;
      
      
       //calculate security tax
       double securityTax=totalSalary*SOCAIL_SECURITY_TAX;
       System.out.printf("Social Security Tax :%.2f ",securityTax);
      
       totalSalary=totalSalary-securityTax;
      
       //calculate medical tax
       double medicareTax=totalSalary*MEDICARE_TAX;
       System.out.printf("Medicare Tax :%.2f ",federalTax);          
       totalSalary=totalSalary-medicareTax;
                  
       double netPay=totalSalary;
       //print net salary
       System.out.printf("Net Pay :%.2f ",netPay);      
   }
}

---------------------------------------

Sample output:

sample run1:

1.Hourly Pay
2.Salaried Pay
Enter your choice :
2
Enter weekly pay
5000
Gross Pay : 5000.00
Weekly Employee
State Tax :300.00
Federal Tax :705.00
Social Security Tax :247.69
Medicare Tax :705.00
Net Pay :3692.97


sampel run2:

    1.Hourly Pay
   2.Salaried Pay
Enter your choice :
1
Enter hourly wage
40
Enter number of hours workd
100
Gross Pay : 4000.00
Hourly Employee
State Tax :240.00
Federal Tax :564.00
Social Security Tax :198.15
Medicare Tax :564.00
Net Pay :2954.38

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