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

Please comeplete the question with JAVA. EXAMPLE OUTPUT: HW6: Paystub for Employ

ID: 3796325 • Letter: P

Question

Please comeplete the question with JAVA.

EXAMPLE OUTPUT:

HW6: Paystub for Employee CSS 161 Fundamentals of Computing By: Hansel Ong Summary So far you have kept track of hours worked for only one employee. However, this is obviously not sustainable as companies typically have more than one employee some companies even have over 100,000 employees! Let's use the object-oriented programming (OOP) paradigm to simplify data collection and storage. Estimated Work Needed This assignment took me about 30-45 minutes to write (not including challenges, but including testing, commenting, and cleanup) in less than 200 lines of code (total across three Java files In other words, you should expect to spend between 135 to 450 minutes working on this assignment. If you've spent more than 7.5 hours working on this assignment, then you are likely struggling with arrays, loops, basic class design, methods, and the use of the new scope and should re-read the lecture slides (and attempt the exercises within, seek help from your fellow classmates, myself, your lab instructor, QSCtutor, as well as online resources. Skills Expected All the skills from previous Assignment(s) Class Object and Design, including but not limited to a Instance Variables a Getter and Setter (including input validation in Setters o Constructor o Methods Assignment Description You will write three class objects (and subsequently submit three java files Paystub Employee Employee Driver Notes ONLY the EmployeeDriver class should have static methods. All the other classes should NOT have static methods or Constants should still be static final The below is the minimum you must include you could include additional instance variables methods, etc. as you need.

Explanation / Answer

package wages;

public class PayStub {
   private double hourlyRate;
   private int[][] hrsWorked = new int[2][7];
   public final double MEDICAL_INSURANCE_RATE = 50.0;
   public final double TAX_RATE = 0.03;
  
   /**
   * Constructor to set hourlyRate to default as 15
   */
   public PayStub() {
       hourlyRate = 15.0;
   }
  
   public double getHourlyRate() {
       return hourlyRate;
   }
   public void setHourlyRate(double hourlyRate) {
       this.hourlyRate = hourlyRate;
   }
  
   /**
   * Set Number of hours worked on that day of the week
   *
   * @param week
   * @param day
   * @param numberOfHrsWorked
   */
   public void editHours(int week, int day, int numberOfHrsWorked) {
       if(week <= 0 || week > 2)
           System.out.println("Invalid week");
       else if(day <= 0 || day > 7)
           System.out.println("Invalid day");
       else if(numberOfHrsWorked < 0 || numberOfHrsWorked > 24)
           System.out.println("Inavlid Number of Hrs");
       else
           hrsWorked[week - 1][day - 1] = numberOfHrsWorked;
   }
  
   /**
   * Prints day by day hours worked
   */
   public void printHours() {
       for(int week = 1; week <= 2; week++) {
           for(int day = 1; day <= 7; day++) {
               System.out.println("Week " + week + ", Day " + day + ", Hours Worked: " + hrsWorked[week - 1][day - 1]);
           }
       }
   }
  
   /**
   * Return total number of hours worked for two weeks
   *
   * @return regularHrs
   */
   public int calRegularHrs() {
       int regularHrs = 0;
       for(int week = 1; week <= 2; week++) {
           for(int day = 1; day <= 7; day++) {
               regularHrs += hrsWorked[week - 1][day - 1];
           }
       }
      
       return regularHrs;
   }
  
   /**
   * Return total number of overtime hours (greater than 8)
   *
   * @return overtimeHrs
   */
   public int calOvertimeHrs() {
       int overtimeHrs = 0;
       for(int week = 1; week <= 2; week++) {
           for(int day = 1; day <= 7; day++) {
               if(hrsWorked[week - 1][day - 1] - 8 > 0)
                   overtimeHrs += (hrsWorked[week - 1][day - 1] - 8);
           }
       }
      
       return overtimeHrs;
   }
  
   /**
   * Prints Pay stub as Week <week>, Day <day>, Hours Worked <hrsWorked>
   */
   public void printPayStub() {
       StringBuilder sbr = new StringBuilder();
       for(int week = 1; week <= 2; week++) {
           for(int day = 1; day <= 7; day++) {
               sbr.append("Week " + week + "," + " Day " + day + ", Hours Worked: " + hrsWorked[week - 1][day - 1] + " ");
           }
       }
      
       System.out.println(sbr.toString());
}

}

package wages;

public class Employee {
   private double hourlyRate;
   private PayStub[] payStubs;
  
  
   /**
   * Constructor to create Employee as per provided hourly rate
   * @param hourlyRate
   */
   public Employee(double hourlyRate) {
       this.hourlyRate = hourlyRate;
   }
  
   /**
   * Add payStub to payStubs array
   *
   * @param payStub
   */
   public void addPayStub(PayStub payStub) {
       if(payStubs == null) {
           payStubs = new PayStub[24];
       }
      
       for(int i = 0; i < payStubs.length; i++) {
           if(payStubs[i] == null) {
               payStubs[i] = payStub;
               break;
           }
       }
   }
  
   /**
   * Print Income History per PayStub
   */
   public void printIncomeHistory() {
       for(int i = 0; i < payStubs.length; i++) {
           if(payStubs[i] != null) {
               System.out.println("-------------PayStub " + (i + 1) + "---------------");
               System.out.println("Regular Hours Worked: " + payStubs[i].calRegularHrs());
               System.out.println("Overtime Hours Worked: " + payStubs[i].calOvertimeHrs());
               double totalIncome = payStubs[i].calRegularHrs() * payStubs[i].getHourlyRate();
               System.out.println("Gross Income: " + totalIncome);
               double deductions = totalIncome * payStubs[i].TAX_RATE;
               System.out.println("Deductions: " + deductions);
               System.out.println("Taxable Income: " + (totalIncome - deductions));
           }
       }
   }

   public double getHourlyRate() {
       return hourlyRate;
   }

   public void setHourlyRate(double hourlyRate) {
       this.hourlyRate = hourlyRate;
   }
  
  
}

package wages;

public class EmployeeDriver {

   public static void main(String[] args) {
       // Create and print a payStub
       PayStub payStub = new PayStub();
       payStub.editHours(1, 3, 9);
       payStub.editHours(1, 6, 4);
       payStub.editHours(2, 4, 12);
       payStub.printPayStub();
      
       // Create employee with hourly rate as $17 and add above PayStub
       Employee employee = new Employee(17);
       payStub.setHourlyRate(employee.getHourlyRate());
       employee.addPayStub(payStub);
      
       // Change hourly rate $17.56, create and new PayStub
       employee.setHourlyRate(17.56);
       payStub = new PayStub();
       for (int week = 1; week <= 2; week++) {
           for (int day = 1; day <= 7; day++) {
               if (week == 2 && day == 4)
                   payStub.editHours(week, day, 12);
               else
                   payStub.editHours(week, day, 0);
           }
       }
       payStub.setHourlyRate(employee.getHourlyRate());
       employee.addPayStub(payStub);
      
       // Print the employee income history
       employee.printIncomeHistory();

   }

}

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