I've looked around for a while and I couldn't find an exactly similar question. I'm writing a program that has a user choose what type of question they will be asked, then they input their answer. If they get it right, a point is added to their score. I can get it to work when the answers are incorrect, but not when they're correct. I know this is happening because the inputted strings do not match what the correct answers are stored as for some reason, but I cannot figure out why. Here's a section of the code:
System.out.println("What school do the Badgers belong to?");
mascotQuestion1 = scan.next();
if (mascotQuestion1.equalsIgnoreCase("University of Michigan")) {
score++;
}
else if (mascotQuestion1.equalsIgnoreCase("don't know")) {
score = (score + 0);
}
else {
score--;
}
Basically, the if and else if statements don't work. Every input is sent to the else statement. What's the problem?
EDIT: So, I tried printing the inputted mascotQuestion1 after entering "University of Michigan", and it came back "University". This is why it wrong, but I don't know how to fix this.