I'm confused on what it is you want... I ran your program and it seems to give the correct output each time.

edit:

oh wait, i see what you want. The easiest way to do this is with if...