Hey All,

Can you guys help with my code? It's giving me a Java Stack Error Message when I try and run the method. I think its because I'm using if without else or I have set something to continously loop. I'm basic beyond belief with java!

Basically I have a bank account and I am trying to setup the following rules for a credit() method.


• maxDepositPerYear has already been deposited this year. In this case the full amount to be deposited is added to the suspense balance and the following message is output in a dialogue box: ‘Limit exceeded. Deposit added to suspense’.
• When added together, the total already deposited this year and the amount to be deposited do not exceed maxDepositPerYear. In this case the whole amount is credited to the balance of the main account, as for the superclass, and the amount deposited this year is updated accordingly.
• If the whole amount were credited to the account, the total deposited this year would exceed maxDepositPerYear. In this case only an amount sufficient to bring the total deposited this year up to maxDepositPerYear can be credited to the main account, with the rest being added to the suspense balance.

My method code:

public void credit(double anAmount)
{
double anAmount1;
double anAmount2;
{
if (this.getDepositsThisYear() + anAmount > getMaxDepositPerYear())
{
this.setSuspense(anAmount);
OUDialog.alert("Limit exceeded. Deposit added to suspense");
}
if (this.getDepositsThisYear() + anAmount < getMaxDepositPerYear())
{
this.credit(anAmount);
this.setDepositsThisYear(getDepositsThisYear() + anAmount);
}
if (this.getDepositsThisYear() + anAmount > getMaxDepositPerYear())
{
anAmount1 = (this.getDepositsThisYear() + anAmount - getMaxDepositPerYear());
anAmount2 = anAmount - anAmount1;
this.setSuspense(anAmount1);
this.credit(anAmount2);
this.setDepositsThisYear(anAmount2);
OUDialog.alert(anAmount + " credited to account, remainder added to the suspense where");

}

}
}