I'm having a bit of difficulty going about this. I need to return the regular (40 hours) and overtime pay (>40) of my worker in my worker class, along with the payTotal. My worker class is a subclass of my Person class. I haven't quite finished it yet but I want to know if I'm heading in the right direction with this class. Here is my code for my current method
String displayWeeklyPay(double hoursWorked){
double overtime;
double regular;
String result;
if (hoursWorked <= 40)
{
payTotal = hourlyPayRate * hoursWorked;
regular = payTotal;
overtime = 0;
}
else{
payTotal = (hourlyPayRate * 40) + ((hoursWorked - 40) * (hourlyPayRate * 1.5));
regular = hourlyPayRate * 40;
overtime = ((hoursWorked - 40) * (hourlyPayRate * 1.5));
}
String overT = String.valueOf(overtime);
String reg = String.valueOf(regular);
String totalPay = String.valueOf(payTotal);
We were told to make this method return a string so I'm not quite sure how I'd return this. I've seen some posts that suggest an array but if I have to pass these values( regular, overtime, paytotal) to my worker constructor later on then will I be able to make the constructor differentiate between the three strings in the array? Thanks