Aug 31, 2014 at 5:23am UTC
Determine the BEST structure to use when you want to output various messages based on a code letter representing a person’s marital status (e.g., ‘m’ for married, ‘d’ for divorced, ‘w’ for widowed, etc).
1)series of if statements
2)if/else
3)switch
4)nested if/else within a switch
thanks
Aug 31, 2014 at 5:33am UTC
What do you think? Try your best educated guess.
Last edited on Aug 31, 2014 at 5:34am UTC
Aug 31, 2014 at 5:37am UTC
i feel that is option 1 as is the most simplest of all. How about you? ;)
Aug 31, 2014 at 5:38am UTC
Don't you think that would be very repetitive? Sounds like a copy-paste-edit nightmare.
Aug 31, 2014 at 5:43am UTC
then is it switch?
Case'D'cout<<"divorced": ;
easier to edit and add other variables?
Aug 31, 2014 at 5:51am UTC
Don't forget a break though.
I would personally use an unordered map though.
Aug 31, 2014 at 7:17am UTC
I have not learn that, if only can choose from the 4 options whats your recommendation?
Aug 31, 2014 at 4:48pm UTC
You had the right idea with using a switch statement ;)