-1
//deposit case
case "deposit":
JOptionPane.showMessageDialog(null,"We accept the following dollar bills:\n1, 5, 10, 20, 50, 100"
+ "\nPlease insert the bill on the console."
+ "\nEnter any other number to stop depositing."
,"Insert Bill",JOptionPane.INFORMATION_MESSAGE);
System.out.println("Insert bills here.");
int deposit = keyboard.nextInt();
int total = 0;
while (deposit==1||deposit==5||deposit==10||deposit==20||deposit==50||deposit==100)
{
total += deposit;
//System.out.println(deposit);
deposit = keyboard.nextInt();
//System.out.println(deposit);
keyboard.close();
// if (deposit!=1||deposit!=5||deposit!=10||deposit!=20||deposit!=50||deposit!=100)
// {
// break;
// }
}
acc.deposit(total);
JOptionPane.showMessageDialog(null, "You deposited "+total+" dollars."
+"\nThe current balance is: $"+acc.showBalance()
,"Deposit into Account" ,JOptionPane.WARNING_MESSAGE);
break;
//withdraw case
case "withdraw":
int money = 0;
String moneyString = JOptionPane.showInputDialog(null,"Please enter amount you want to withdraw"
,"Withdraw from Account",JOptionPane.QUESTION_MESSAGE);
if (moneyString == null||moneyString.length()==0)
{
money = 0;
}
else {
money = Integer.parseInt(moneyString);
}
acc.withdraw(money);
break;
ループ内の 'keyboard'を' close() 'しないでください... – brso05