I really hate dislike constructs like what you have on line 6. Much better to use a switch statement with a quit case & a default clause to catch bad input, and put the whole thing in a bool controlled while loop.
I have written a number of replies about this, here is one of them:
hahaha. If you ask me, as long as it works, im fine
Just trying to show some better methods. IMO it is much better to write elegant code, and coders should always be prepared to learn new things. If you aren't ready for this at your early stage, then you may be making life difficult for yourself in the long run.
Also consider the effort that is put in by people who answer questions - are you still happy to go with your bad code, and ignore the advice given that was aimed at trying to help you out?
Further to my suggestion in my previous post, I assert that your code is not scalable - what if you had 20 or 50 different options? I can think of lots of situations where this is the case.
Just trying to show some better methods. IMO it is much better to write elegant code, and coders should always be prepared to learn new things. If you aren't ready for this at your early stage, then you may be making life difficult for yourself in the long run.
Also consider the effort that is put in by people who answer questions - are you still happy to go with your bad code, and ignore the advice given that was aimed at trying to help you out?
Further to my suggestion in my previous post, I assert that your code is not scalable - what if you had 20 or 50 different options? I can think of lots of situations where this is the case.
- I would hope that he wouldn't use that format with 20-50+ different options.