im trying to make a program where only if you say yes to opening an account you can deposit money in it but im not sure on how to do it in my program the scanner inside of the if statemnt isnt working in other word if you said yes to opening an account after some steps i want to ask from user if he wants to deposit money or not
import java.util.Scanner;
public class main{
public static void main(String[] args) {
System.out.println(bank.Name);
System.out.println(bank.location);
System.out.println("bank id is: " + bank.bankId);
customer open = factory.getInstance(1);
customer close = factory.getInstance(2);
customer deposit = factory.getInstance(3);
System.out.print("you want to open or close account ");
Scanner y= new Scanner(System.in);
String str= y.nextLine();
if(str.equals("open") ){
System.out.println(open.getOpen());
System.out.print("would you like to deposit money in your account ");
Scanner isdeposit= new Scanner(System.in);
String x= isdeposit.nextLine();
if(x.equals("yes") ){
System.out.println(deposit.getDeposit());
}
}
else if(str.equals("close")){
System.out.println(close.getClose());
}
else{
System.out.println("invlaid input");
}
}
}