嗨,伙计们,当用户申请透支时,我正在努力申请50美元的透支费用。我的代码如下:
public void Withdraw(double amount){
int Charge = 50; //overdraft charge
if (balance - amount < 0) {
if ((balance -Charge)- amount <= -300) { //If withdraw + overdraft charge goes over -300 then overdraft limit has been exceeded
System.out.println("You have exceeded your Overdraft Limit, you will now be returned back to the menus");
} else { //if not exceeding bank balance
balance -= amount ; //subtract amount from balance
System.out.println("/");
}
}
}
它目前所做的只是在申请透支时显示负数,而不减去超额费用我怎样才能说明当用户申请透支时又需要额外收费50?
答案 0 :(得分:1)
您需要修改代码,使其看起来像这样
} else { //if not exceeding bank balance
balance -= (amount + Charge) ; //subtract amount and charge from balance
System.out.println("You have withdrawen £" + amount);
System.err.println("You now have a balance of £" + balance);
System.out.println("/");
}