....

...
Last edited on
First, if you press the <> button to the right of your post, it will make code tags. Code is easier to read in code tags. I could also give you line numbers to point things out.

ValidateNumbers() only accepts two arguments, but you pass it three in your while loop.

ValidateNumbers returns void, but you do numberValid = ValidateNumbers(hours,0.00,112.00);.

FALSE isn't part of standard c++, use false instead (notice what the tags did?). numberValid is an int, so you can't give it false anyway.

So I think to start, make numberValid a bool, and have ValidateNumbers return bool.

That function is pretty crazy in general though. It doesn't really do anything.
Is ValidateNumbers a different function? Provide the code for it as well, so it will be possible to see what is going wrong. Please use the code tags for code.

One more thing: you do not increase the retryCount within the loop.
...
Last edited on
In the attitude of trying to help, what is that function even supposed to do?

Edit: I also see you've #define FALSE 0 . FALSE is fine to use, and perhaps that's what your teacher wants as well.
Last edited on
Restrict the hourly payrate to a maximun of $99.99 and
Restrict the hours worked to a maximun of 112 hours.
Pass the arguments by reference:
void validateNumbers(float& hours,float& payrate)

Here's the code for payrate:
1
2
3
4
5
6
7
8
9
10
11
12
13
float maxPayrate = 99.99f;

printf(" Enter the payrate ==> ");
do
{
  int scanSuccess =  scanf("%f",payrate);
  if (scanSuccess != 1)
    printf("Not a number, please try again: ");
  else if (payrate > maxPayrate)
    printf("Value must be less than %6f, please try again", maxPayrate);
  // Also maybe if payrate was less than zero
}
while (scanSuccess != 1 || payrate > maxPayrate);
Last edited on
Topic archived. No new replies allowed.