QuestionQuestion

The assignment
Write a Java program that can be used to calculate the weekly salary for hourly paid employees. The program initially accepts the employee’s id, the number of hours worked, and the hourly pay rate. An employee may work additional hours. When this happens, the additional number of hours must be added to the original amount, and the salary is re-calculated. The program must output on separate lines the employee’s id number, the number of hours worked, the hourly pay rate, and the salary, for each employee. In addition, the program must also output the total amount of money paid out by the company.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class Payroll {

    // employee id
    private String employeeId;
    private double salary;

    // Instance variables for number of hours worked, and hourly rate of pay
    private double workedHour;
    private double hourlyRate;

    // Class variable for accumulating the weekly payroll.
    private static double totalPayout = 0;

    // A mutator instance method that calculates an employee salary,
    // and accumulates the weekly payroll
    public void calculateSalary() {
       salary = 0.0;
       salary = workedHour * hourlyRate;
       totalPayout += salary;
    }

    /**
    * update working hour recalculate salary and total payment
    *
    * @param hour
    */
    public void increaseHours(double hour) {
       if (hour > 0) {
            double extra = hour * hourlyRate;
            salary += extra;
            workedHour += hour;
            totalPayout += extra;
       }
    }

    // Constructor that accepts the employee’s id number,
    // the number of hours worked, and the hourly rate per employee.
    public Payroll(String employeeId, double workedHour, double hourlyRate) {
       this.employeeId = employeeId;
       this.workedHour = workedHour;
       this.hourlyRate = hourlyRate;
    }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$14.40
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats