The following is part of a code for a photocopy cost calculator program. I am having a hard time with the if/else part and I can't figure out what is wrong. The program reads a "paper format" input which is placed into FormatPapier. Prior to this, the user entered the number of pages for the original document and the the amount of copies wanted. The if/else part is to only output the "recto / recto-verso" option menu when the number of page on the original copy is higher than 1 or 2 (depending if the format chose was 8x11 or 11x17). If that value equals 1 or 2, the recto option is automatically put into the corresponding variable.
Unfortunately, the program won't go past the if line, so something must be wrong with my condition but I can't figure it out. Am I missing something blatantly obvious, or what ? Thanks !
I do not know what your program is supposed to do, but when things are not working I like to place checkpoints in parts of the code. This way I see where it goes or does not go.
For example.
Now if I know 100% this set if input should run doSomthingElse(), and it does not, I can see what happens instead. This method solved so much logic errors for me. So try adding a few of these, see what your code produces, and find those annoying logic errors.
Line 1 to 12 is where the user is supposed to choose what paper format they'd like their photocopies printed on.
Line 17 to 28 is the second menu where the user picks recto or recto-verso printing.
The if on line 15 is to make sure the recto-verso menu is not showed in the cases that:
a) The paper format chosen is 8x11 or 8x14 AND the original document only has one page (for obvious reasons)
b) The paper format chosen is 11x17 and the original document has either 1 or two pages. (Because it is assumed that the original is 8x11 and you can fit two pages on one 11x17)
Thanks for the checkpoints tip, I will certainly use it when needed. I just realized that, since I used _getche() to put a value into FormatPaper, I need to use ' ' in my condition statement.
I've modified my code and it seems to be working, but feel free to add anything else that could help improve or stabilize it.