2 回答
TA贡献1827条经验 获得超7个赞
似乎您忘记将费用参数传递给 adjust() 方法。以下代码工作得很好
public void monthlyFee(double fee) { //monthly fee for bank accounts
for(int i = 0; i < bank.length; i++) {
if(bank[i] != null) {
System.out.println(bank[i].adjust(fee));
} //I have tried BankAccount.adjust() and couldn't work, bank[i].adjust() nothing seems to work
}
}
创建银行1
一个帐户 Joe Mac 拥有帐户 1234,余额为 $1000.00
两个帐户 Joe Mac 拥有帐户 1234,余额为 $1000.00 Sally Ride 拥有帐户 2345,余额为 $2000.00
三个帐户 Joe Mac 拥有帐户 1234,余额为 $1000.00 Sally Ride 拥有帐户 2345,余额为 $2000.00 Pat Armstrong 拥有帐户 3456,余额为 $3000.00
月费 997.05 1997.05 2997.05 Joe Mac 拥有账户 1234,余额为 $997.05 Sally Ride 拥有账户 2345,余额为 $1997.05 Pat Armstrong 拥有账户 3456,余额为 $2997.05
错误:
没有发现错误!!!
TA贡献1886条经验 获得超2个赞
很简单:当您检查您的测试代码时,您会发现在调用该adjust()方法时它传递了一个双精度值!
您的其他代码(导致错误的代码)在调用该方法时似乎没有传递任何双精度!
添加回答
举报