[Solved] Calculating weekly salary – Total value not correct


The problem lies in this method.

public void increaseHours (double x)
{
    Hours = increaseHours + Hours;
}

Firstly, you are using the wrong field (increaseHours) instead of x. So please delete this line:

private double increaseHours = 10;

And now update your method:

public void increaseHours (double increaseHours)
{
    Hours = increaseHours + Hours;
    TotalPayout += increaseHours * Hourly_Rate;
}

This will fix your problem for now but I highly suggest not using a static field for TotalPayout – which will require you to redesign slightly.

Also, some style pointers. Use camel case starting with small letter for variables / fields. e.g. totalPayout instead of TotalPayout. etc.

Welcome to S.O. and java world and good luck further.

1

solved Calculating weekly salary – Total value not correct