I'm new to Java and I can't figure out how to solve this problem. Whenever I try to run the program, after putting in a number for the "please enter 5 digit number" entry, the program goes directly to the else statement: "ERROR: Please enter a D, W, B, or X"
Here's the entire code:
import java.util.Scanner; // needed to use Scanner for input
public class SeminoleBank_A {
public static void main(String[] args) {
//Create Scanner object
Scanner input = new Scanner(System.in);
//Declare and initialize
int deposit, withdrawal;
int balance = 0;
int number;
String menuChoice = "";
//Display welcome message “Seminole Bank”
System.out.println("\n********************************************************");
System.out.println(" Welcome to Seminole Bank! ");
System.out.println("********************************************************");
//Ask user to enter 5-digit Account Number
System.out.print("Please enter your 5-digit Seminole Account Number: ");
//Read user's Account Number
number = input.nextInt();
//Display "Thank You"
System.out.println("Thank you!!");
//Prompt user for year born
System.out.print("Enter D for deposit, W for withdrawal, B for balance, X to exit the menu: ");
// Read user's menu choice
System.out.println(menuChoice.toUpperCase() );
while (menuChoice != "X") {
if (menuChoice == "D"){
System.out.print("Enter the amount of the deposit: ");
deposit = input.nextInt();
System.out.printf("Account Number: " + number + "has a current balance of %.2f $: " + (balance + deposit));
}//end of if
else if (menuChoice == "W"){
System.out.print("Enter the amount of the withdrawal: ");
withdrawal = input.nextInt();
System.out.printf("Account Number: " + number + "has a current balance of %.2f $: " + (balance + withdrawal));
}//end of else if
else if (menuChoice == "B"){
System.out.printf("Account Number: " + number + "has a current balance of %.2f $: " + balance);
}//end of else if
else {
System.out.println("ERROR: Please enter a D, W, B, or X: ");
}//end of else
}//end of while
System.out.println("Thank you for being a loyal Seminole Bank customer!");
}//end of main
}//end of class
Any help would be greatly appreciated.