The class Worker is defined below. The class includes the method getEarnings, which is intended to return the total amount earned by the worker.
public class Worker
{
private double hourlyRate;
private double hoursWorked;
private double earnings;
public Worker(double rate, double hours)
{
hourlyRate = rate;
hoursWorked = hours;
}
private void calculateEarnings()
{
double earnings = 0.0;
earnings += hourlyRate * hoursWorked;
}
public double getEarnings()
{
calculateEarnings();
return earnings;
}
}
The following code segment appears in a method in a class other than Worker. The code segment is intended to print the value 800.0, but instead prints a different value because of an error in the Worker class.
Worker bob = new Worker(20.0, 40.0);
System.out.println(bob.getEarnings());
Which of the following best explains why an incorrect value is printed?
The variable earnings in the calculateEarnings method is a local variable.

Respuesta :

The variable earnings in the calculate Earnings method is a local variable. It is usually paid in the form of incentive pay, bonus, or commission.

Variable compensation typically represents an employer paying an employee based on performance results. Employees typically receive this type of compensation in addition to their basic salary.

Usually paid in the form of performance bonuses, bonuses or commissions. It is determined based on two main factors: employee performance and overall company performance. Most companies include a process of goal setting, based on which variable payments are made. Variable compensation is usually expressed as a percentage of a fixed salary. At the junior level, variable compensation percentages typically range from 10% to 15% of fixed compensation. As the employee is promoted, the variable salary component increases. So the numbers fluctuate from 15% to 30% at the middle level and rise from 30% to 50% at the upper level.

To know more about variable salary, visit:-

https://brainly.com/question/28147102

#SPJ4