Introduction
Requirement
CS37 Programming Assignment 3
Total Point: 12 Due Date: 11/07/2016, Monday
Tasks:
A.Create a SavingsAccount class.
1.Define a static data member annualInterestRate (type double value such as 0.03, i.e. three percent) for all the savings accounts.
2.Each instance of the class contains the following private data members:
accountNumber (integer from 1000 to 4999),
accountOwner (owner’s name as a string),
accountBalance (type double value).
3.Provide the following member functions:
calculateMonthlyInterest() computes the monthly interest using formula:
m_interest = accountBalance * annualInterstRate / 12;
This interest should be added to accountBalance.
deposit(double amount) adds amount to accountBalnce.
withdraw(double amount) deduct amount from accountBalance. No overdraft is allowed. The function should return a false if overdraft, otherwise returns a true value.
checkBalance() to print out the current accountBalance. This is a const function and will not modify the content of savingsAccount object.
4.Provide a static member function modifyInterestRate that sets the static member annualInterestRate to a new value (for example, 0.05 for five percent).
5.Define a friend function, transferFund(SavingsAccount a, SavingsAccount b, double amount) which withdraws $amount from account a and deposit it to account b. The function should return false if transfer fails (due to insufficient fund), else returns a true.
B.Write a driver program to test class SavingsAccount.
Create three instances of SavingsAccount, say savings1, savings2 and savings3, using constructors with initializer list to set the values of accountNumber, accountOwner and accountBalance.
Set the annualInterestRate to 3 percent (0.03). Then calculate the monthly interest and print the new balances for each of the savers.
Make some transactions (deposits and/or withdraws) from each savings account. Print some messages showing these transactions (accountNumber, amount of transaction and resulting balance).
Check and print out the balances of all three accounts.
Then set the annualInterestRate to 5 percent (0.05), calculate the next month’s interest and print the new balance for each of the savers.
Transfer a small amount of fund (say $100) from one account to another using the transferFund() function. Print out the message about this transaction (the amount transferred, the from/to accountNumber and accountBalnce, transfer success/fail, etc.).
C. Turn in the source code, console I/O dialog, and program output for grading.