Hi,
Im trying to filter a user number entered by the user so that it is between 3 and 31 and odd. I also want the prompt to enter the user number to loop if the user number entered does not meet the requirements.
This is what i have:
bool validUserInput (true);
do {
cout << "Please enter an odd value between 3 and 31: " << endl;
cin >> rate;
myWaveForm.getSampleValue( rate );
if ( rate % 2 != 0 ) validUserInput = false ;
if ( rate < 3 ) validUserInput = false;
if ( rate > 31 ) validUserInput = false;
}
while (validUserInput);
This works perfectly within the range of between 3 and 31 and being odd but allows any number regardless of odd or even outside of the limits. What am i doing wrong?