0

Hello and thank you for your time.
I am currently having an issue with a scanner input being ignored within an if statement.
My scanner is called keyIn, and the input being ignored is in line: this.addMemo(keyIn.nexLine());

relevant code:

public void action()
{
  for (boolean loop = true; loop != false;)
  {
     System.out.println("m = create Memo \nx = Exit");
     this.changeReply(keyIn.next());
     if (this.reply().equalsIgnoreCase("m"))
        this.addMemo(keyIn.nextLine());
     if (this.reply().equalsIgnoreCase("x"))
        loop = false;
  }
}
public void addMemo (String newMemo)
{ 
   memoNum = +1;
   memo = memo + "\n" + memoNum + ".) " + newMemo;
   System.out.println(memo);
   System.out.println("");
}

When ran, the current code ignores the input prompt and simply fills newMemo with " ". I can tell because when troubleshooting, I changed newMemo's default value to 7, and this code changes it back to blank. I will note that this function was working before the for loop was integrated, but a few things have changed since then, so I can't be sure that's the issue.

output:
m = create Memo
x = Exit
m
Memos:

1.)
m = create Memo
x = Exit

Any insights will be appreciated, thank you.

0 Answers0