我正在编写一个程序来为用户提供一个菜单。在他输入数字后,我使用开关来决定用户应该输入哪个参数。无论如何,在一种情况下(情况1)我需要用户的输入。但是在用户输入第一个输入后,程序会中断开关并执行开关之后的操作。
代码 :
案例一:
case 1:
System.out.println("Enter the Amount :");
currentAccount.debit(scanner.nextDouble());
System.out.println("Want anything else(yes/no)?");
String input=scanner.nextLine();
if(input.equalsIgnoreCase("no")){
isFinished=true;
currentAccount=null;
System.out.println("SignedOut successfully");
}
break;
输出:
Choose an opearation:
1.withdraw.
2.deposit.
3.transaction history.
1
Enter the Amount :
100
Debit amount exceeded account balance.
Want anything else(yes/no)?
--------- Mhd Bank ---------
logined as :
--------------------------------
Choose an opearation:
1.withdraw.
2.deposit.
3.transaction history.
森林海
相关分类