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

Design a payroll class that stores and employee\'s 10 number, name and gross pay

ID: 3624041 • Letter: D

Question

Design a payroll class that stores and employee's 10 number, name and gross pay. The class should have a method that calculates the employee's ne pay as follows: Texas tax: 5.25% Federal Tax: Federal Insurance Contributions Act: 7.65% of grass pay net pay = grass pay - state tax - federal tax - FICA with holdings Also, write the application named as Two Weekly paroll Report that has a loop asking the user for: employee ID number and the gross pay then pass these value to an instance of the above payroll class. The state tax, federal tax, FICA with holdings and net pay should be displayed as bellow format: Employee ID: 12345 Employee Name: Bill White Gross pay : $ 3,000.00 State tax: $187.5 Federal tax: $750.0 FICA with holdings: 229.5 Net pay: 18933.0 the loop only terminates when 0 is entered for the employee number. Input validation: Do not accept negative numbers for any the items entered.

Explanation / Answer

import java.util.Scanner; //Needed for scanner class. 02 03 public class Payroll 04 { 05 private String EmployeeName; 06 private int IDnumber; 07 private double HourlyPayRate; 08 private double HoursWorked; 09 private double GrossPay; 10 11 /** 12 Constructor 13 @param Name The name to store in EmployeeName. 14 @param ID The ID to store in Employee ID number. 15 */ 16 public Payroll(String Name, int ID) 17 { 18 EmployeeName = Name; 19 IDnumber = ID; 20 } 21 public String getEmployeeName() 22 { 23 return EmployeeName; 24 } 25 public int getIDnumber() 26 { 27 return IDnumber; 28 } 29 public void setHourlyPayRate(double HourlyRate) 30 { 31 HourlyPayRate = HourlyRate; 32 } 33 public double getHourlyPayRate() 34 { 35 return HourlyPayRate; 36 } 37 public void setHoursWorked(double hoursWorked) 38 { 39 HoursWorked = hoursWorked; 40 } 41 public double getHoursWorked() 42 { 43 return HoursWorked; 44 } 45 public double getGrossPay() 46 { 47 return HourlyPayRate * HoursWorked; 48 } as you can see I created the constructor that passes the name ID as arguments.now this is the test class view source print? 01 import java.util.Scanner; //Needed for Scanner class. 02 03 public class PayrollTest 04 { 05 public static void main(String[] args) 06 { 07 String EmployeeName; 08 int IDnumber; 09 double HoursWorked; 10 double HourlyPayRate; 11 double GrossPay; 12 13 //Create a Scanner object for keyboard input. 14 Scanner keyboard = new Scanner(System.in); 15 16 //Create a payroll object, passing EmployeeName and IDnumber 17 // as arguments to the constructor. 18 Payroll pay = new Payroll(EmployeeName, IDnumber); 19 20 21 //Get the employee's name. 22 System.out.println("Enter an employee's name: "); 23 EmployeeName = keyboard.nextLine(); 24 25 //Get the employee's ID. 26 System.out.println("Enter the employee's ID " ); 27 IDnumber = keyboard.nextInt(); 28 29 //Get the number of hours worked by the employee. 30 System.out.println("Enter the amount of hours worked by this employee: "); 31 HoursWorked = keyboard.nextDouble(); 32 33 //Get the hourly pay rate of the employee. 34 System.out.println("Enter the hourly pay rate for this employee: "); 35 HourlyPayRate = keyboard.nextDouble(); 36 37 //Get the Gross Pay of the employee. 38 System.out.println("The gross pay of " + EmployeeName + " is: " + pay.getGrossPay()); 39 } 40 }

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