1) The constructor initilizes the balance if greater than 0 and sets the other properties to 0. 2) If the transaction is greater than 0 then a Deposit is made else a Withdraw is made. 3) The balance is increased with a deposit but decreased if a Withdrawal. This assumes the Withdrawal is less than the balance. Can't have a negative balance. Tell the user that he is trying to make a withdrawal that exceeds his balance. 4) When a WithDrawal is made increment FreqWithDraw else if a Deposit is made increment FreqDeposit. 5) The toString procedure outputs all properties. 6) The total procedure tells you how much you will have in savings given the interest rate and the amount of time. Total(float savint,int time) returns Balance*(1+savint)^time. Utilize a for loop for this calculation. 7) See if you can write a recursive procedure that does the same thing as 6). Call it TotalRecursive. 8) Think of what follows as pseudocode. The random number generator below produces a number between 0 and 32,767. If you fashion a random number that will do the same then you will get positive and negative transactions (-500,500). The output simply calculates the current balance with a 10 percent interest rate and 7 years worth of compounding. Also, you tried to start out with a negative balance which should have been initialized to 0. |
|
|
|
|