if (status==true)
This can be written:
The false version looks like this:
Try to avoid global variables, they seem easy now, but they lead to bad code with hard to find errors. Send each function the variables it needs. Btw I think the names you have for them are too long, consider these:
1 2 3 4 5 6 7 8
|
const double RANGED_NUMBER_FOR_PAY_RATE_1=7.50;
const double PayLowerLimit= 7.50;
const double RANGED_NUMBER_FOR_PAY_RATE_2=18.25;
const double PayUpperLimit= 18.25;
const int RANGED_NUMBER_FOR_HOURS_WORKED_1=0;
const double HoursLowerLimit = 0.0; // made these double so as to not mix the types
const int RANGED_NUMBER_FOR_HOURS_WORKED_2=40;
const double HoursUpperLimit = 0.0;
|
If using do loops, put the while part on the same line as the closing brace, so it doesn't look like a while loop
1 2
|
//end of do while loop to confirm hourly pay
} while (!status);
|
This part doesn't do what you think it does:
1 2
|
}//end of do while loop to enter another employee's payroll
while(doAgain=="yes" || "Yes" || "YES");
|
Rather than trying to account for every combination of spelling and mixing of upper and lower case, just get input as a single char and convert to uppercase with the toupper function. Then you can compare to one thing:
'Y'
At the moment the form of the conditional is wrong, one has to do this:
1 2 3
|
//end of do while loop to enter another employee's payroll
} while(doAgain=="yes" || doAgain == "Yes" || doAgain == "YES");
|
It would still fail on input of "YEs" plus all the other combinations not mentioned. But as I say above, you can avoid that.
This:
1 2 3 4 5 6 7 8 9
|
bool inputValidationCheckOne (double hourlyPayRate)
{
if (hourlyPayRate>=RANGED_NUMBER_FOR_PAY_RATE_1 && hourlyPayRate<=RANGED_NUMBER_FOR_PAY_RATE_2)
return true;
else
return false;
}//end inputValidationCheckOne
|
Can be written:
1 2 3 4 5 6
|
bool ValidateHourlyPayRate (const double hourlyPayRate,
const double PayLowerLimit,
const double PayUpperLimit
)
{ return hourlyPayRate>=PayLowerLimit && hourlyPayRate<=PayUpperLimit;
}
|
I changed the name of the function to something more meaningful, made the parameters const, one return statement is sufficient - the condition evaluates to true or false, and used the variables names I mentioned earlier.
Hope this helps a bit :+)