I need to validate the moduleCode by a do...while loop.
But my code does'nt exit the loop - Not sure if I did right thing by declaring the string ABC111 before the loop - please help urgently
using namespace std;
// function inputAndValidate should be inserted here
void inputAndValidate(string &moduleCode,int &numberHours)
{
string ABC111,DEF112,XYZ113;
do
{
cout << " Enter module code: ";
cin >> moduleCode;
}
while ((moduleCode!=ABC111) || (moduleCode!=DEF112) || (moduleCode!=XYZ113));
// while (moduleCode != ABC111);
// ||(moduleCode != DEF112) || (moduleCode != XYZ113));
cout << " Enter number of hours: ";
cin >> numberHours;
}
int main ()
{
string moduleCode;
int numberHours;
inputAndValidate(moduleCode, numberHours);
cout << " The module code is " << moduleCode;
cout << " and the number of hours is " << numberHours << endl;
return 0;
}