I am in my first semester of college learning Java. This will be probably a pretty basic loop for you all but I am truly stuck. Now please I am taking suggestions/help but I do not want this code completed for me. I want to learn this code. Thank you!
Context: Write a routine that will read words from the keyboard until the word “done” is entered. For each word except “done”, report only if its first character is equal to its last character.
MY WHILE Loop Code:
while (word != "done") // Test Phase
{
if (word != "done")
{
System.out.println("End While Loop Version");
break;
}
else
{
System.out.println("Next Word: " + word);
System.out.println("Char " + first + " appears at the start and end of " + word);
}
count++;
}
Now I know the break;
is messing up my console output. But I do not know how else to stop the program OR move onto the else condition. I also have to use a simple While Loop. (I have to do all 3. Done with for
.)