-2
System.out.print ("Create a savings account? Enter yes or no: ");
String createSavingsAccount = console.readLine();
if (createSavingsAccount == "yes")
{
    System.out.print ("Enter the balance in the savings account: ");
    savingsBalance = Double.parseDouble(console.readLine());
} 

When I enter yes, the program skips the if statement and goes back to the main menu. How do I get it to check the user input?

user3479783
  • 69
  • 1
  • 2
  • 10

1 Answers1

0

use:

if (createSavingsAccount.equals(("yes")){
...
}
roeygol
  • 4,908
  • 9
  • 51
  • 88
  • 1
    For future reference: this is not a good answer because it does not explain what the problem is and how this solves it. This question is very commonly asked so you should refrain from answering these in a lesser form but instead flag the question as a duplicate of the comprehensive post on the subject. – Jeroen Vannevel Jan 17 '15 at 00:04
  • If you're talking to @JeroenVannevel, he didn't ask a question. If you're not, your comment is incomprehensible. – user207421 Jan 17 '15 at 01:19