Your scope is screwed up all over the place, need to make sure the complete if/else is enclosed with {}, as it is most of your else’s don’t have anything to connect to.
while (!sentenceInput.equals ("STOP")) {
if (sentencePunct == '?')
{
if (remainder == 0) {
System.out.println("Yes");`
System.out.println("Please Input another sentence (terminate with \"STOP \")");
sentenceInput= myScanner.nextLine();
}
else {
System.out.println("No");
System.out.println("Please Input another sentence (terminate with \"STOP \")");
sentenceInput= myScanner.nextLine();
}
}
else if (sentencePunct == '!') {
System.out.println("Wow!");
System.out.println("Please Input another sentence (terminate with \"STOP \")");
sentenceInput= myScanner.nextLine();
}
else {
System.out.println("You always say " + sentenceInput);
System.out.println("Please Input another sentence (terminate with \"STOP \")");
sentenceInput= myScanner.nextLine();
}
}
}
2
solved Ttrying to loop until user types in “Stop”