My program waits for user input and, if necessary, processes it. I need to check the user’s input to make sure that he meets certain criteria, and if he does not fulfill all these criteria, he will be rejected.
The pseudocode looks something like this:
if (fulfills_condition_1)
{
if (fulfills_condition_2)
{
if (fulfills_condition_3)
{
}
else
cout << error_message_3;
}
else
cout << error_message_2;
}
else
cout << error_message_1;
There is a possibility that the number of these conditions may increase, and I was wondering if there would be an easier way to represent this using a switch or something like that instead of a lot of cascading operators if.
I know there is an opportunity to use
if (fulfills_condition_1 && fulfills_condition_2 && fulfills_condition_3)
else
error_message;
but it is less useful than the first, and does not say where the problem is.
, .. condition_1 , condition_3, if , ?