Friday, 13 September 2013

Depending on where I put the "println" it only sometimes works

Depending on where I put the "println" it only sometimes works

Below is a snip from my code. The problem is it is not printing out the
"yay! keep smiling!" at the end. It only prints it if I place the println
before the if loop. How can I fix this? I am sorry if this is a stupid
question, I am new to programming.
for (int z = 0; z <= p; z++) {
char guessCorrelation = correctWord.charAt(z);
if (guessCorrelation == input) {
String temp = dashword.substring(0, z) + guessCorrelation +
dashword.substring((z + 1), (p));
dashword = temp;
System.out.println(dashword);
decider = 1;
if (dashword.equals(correctWord)) {
System.out.println("I knew you had it in you to save gumbo!");
}
}
}
System.out.println("yay! keep smiling!");

No comments:

Post a Comment