Hi mwu,
This is really the same subject as your other post, and we are now all giving the same advice all over again.
I am sure I mentioned in one of your other posts, about what to do with upper & lower case input. That is use either the
toupper
or
tolower
functions, thus cutting the logic in half - only test for one not both.
Then you won't have to have ugly,
UGLY,
UGLY constructs like this:
while (choice != 'C' && choice != 'c')
Sorry
tcs, I am sure you understand that I am mortally opposed to constructs like that :+D lol
Did I (& others) mention using a switch for this as well ? There is no need to have the choice of C as a condition in the loop. Instead use a
bool quit
variable, which is set inside the
case: 'C'
, now the end condition for the while loop uses the
bool
variable:
1 2 3 4 5 6
|
bool quit = false;
while (!quit)
{
// switch statement
}
|
Also, each case: should call a function - that makes it much easier to understand, primarily because the whole switch becomes shorter. Don't forget the default case to catch bad input.