posted 10 years ago
Also, if you were wondering why your program prints out "Date is invalid" multiple times, it's because your if-else statements are all executed independently of each other. That is, each one of them will execute regardless of what already happened with any previously executed if-else statements. You could chain your if-else statements to make them dependent on the results of previous ones.
This code will always result in two actions being executed: (action1 or action2) and (action3 or action4)
In order for action4 to execute, only condition3 has to be false; it doesn't matter what condition1 is.
The code below will result in exactly one of action1, action2, action3, or action4 being executed:
In order for action4 to execute, (condition1 && condition2 && condition3) has to be false. Do you see the difference?