----------------------------------------- SavingAccount ------------------------
ID: 3614027 • Letter: #
Question
-----------------------------------------
SavingAccount
-----------------------------------------
- balance : double
- annualInterestRate : double
- lastInterest : double
------------------------------------------
+SavingAccount(bal: double, rate: double)
+deposit(amount: double):void
+withdraw(amount: double):void
+addInterest(): void
+getBalance():double
+getInterestRate(): double
+getLastInterest(): double
------------------------------------------
a.
Ask the user for the amount deposited into the account during themonth. Use the class method to add this amount tot the accountbalance.
b.
Ask the user for the amount withdrawn from the account during themonth. Use the class method to subtract this amount from theaccount balance.
c.
Use the class method to calculate the monthly interest.
two output of example..
Enter the savings account's starting balance: 100
Enter the savings account's annual interest rate: .12
How many months have passed since the account was opened? 1
Enter the amount deposited during month 1: 100
Enter the amount withdrawn during month 1: 0
Total deposited: $100.00
Total withdrawn: $0.00
Interest earned: $2.00
Ending balance: $202.00
Enter the savings account's starting balance: 1000
Enter the savings account's annual interest rate: .12
How many months have passed since the account was opened? 3
Enter the amount deposited during month 1: 100
Enter the amount withdrawn during month 1: 0
Enter the amount deposited during month 2: 110
Enter the amount withdrawn during month 2: 10
Enter the amount deposited during month 3: 120
Enter the amount withdrawn during month 3: 20
Total deposited: $330.00
Total withdrawn: $30.00
Interest earned: $36.34
Ending balance: $1,336.34