I want the do while loop to check to see if the entered input is R OR P. I think it is checking for both and when I get to that part when I run, it pauses for a minute and then I get "CPU Limit Exceeded (core dumped). On another related note, am I in danger of breaking something?
/************************************************/
/* Name: servcode */
/* Description: Get service type */
/* Parameters: N/A */
/* Return Value: servcode */
/************************************************/
char servcode()
{
char servcode = 'a'; // Define variable for service code
char serviceyn = 'n'; // Define variable for user verify
int i = 1; // Define variable for sentinel loop
do {
cout << "\n" << "\n" << "Please enter your service code, [R]egular or [P]remium: " << "\n";
cin >> servcode;
while ((servcode != 'R', 'P') && (i < 3));
{
cout << "\n" << "Error - invalid service code, please try again.";
cout << "\n" << "Please enter your service code: ";
cin >> servcode;
i++;
if (i == 3)
{
cout << "\n" << "Too many invalid attempts, program terminating." << "\n"
<< "Have a nice day. " << "\n" << "\n";
exit (0);
} //end if
} //end while
cout << "\n" << "You entered: " << servcode << "\n"
<< "Is that correct? [y,n]";
cin >> serviceyn;
} while (serviceyn != 'y'); // end do/while loop
return servcode;
}