K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
All things are lawful, but not all things are profitable.
Damien O Sullivan wrote:I've removed the 'else if' and replaced it with just an 'else', but it still hasn't solved the problem.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
ExceptionCharles D. Ward wrote: . . . you should NEVER use == with booleans. . . .
Well, what is supposed to happen then? Your else block looks as if you had guessed about what to write.What is 6 times 9?
42
Knute Snortum wrote:What's wrong with this code?
Campbell Ritchie wrote:
ExceptionCharles D. Ward wrote: . . . you should NEVER use == with booleans. . . .
if (b1 == b2) …
Damien O Sullivan wrote:Should it be (AnswerIsCorrect)
You sure about that? XOR returns whether the two are different.Junilu Lacar wrote: . . .
You can use the XOR operator which returns true if both booleans are the same
. . .
Campbell Ritchie wrote:
You sure about that? XOR returns whether the two are different.Junilu Lacar wrote: . . .
You can use the XOR operator which returns true if both booleans are the same
. . .
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
All things are lawful, but not all things are profitable.
Damien O Sullivan wrote:Can you give me a hint as to what I should do next please.
Damien O Sullivan wrote:I've had to scrap my original code 'cause it was becoming too complicated so this is what I have at the moment:
Damien O Sullivan wrote:Shouldn't the final Else run the If part again? Instead it just ends the program
Junilu Lacar wrote:
Damien O Sullivan wrote:Shouldn't the final Else run the If part again? Instead it just ends the program
if-else doesn't work like that. It's a simple, straight through execution. That is, given something like this:
if the condition evaluates to true, execute the body of the if-statement
otherwise execute the body of the else clause
After this is done, execution continues to whatever follows, it does not go back to the if part. Only a loop will do what you think should be happening.
Damien O Sullivan wrote:What should I use so to get the program to repeat the same question again?
Don't get me started about those stupid light bulbs. |