Answer:
See explaination
Step-by-step explanation:
// Defination of MoneyMarketAccount CLASS
MoneyMarketAccount::MoneyMarketAccount(string name, double balance)
{
acctName = name;
acctBalance = balance;
}
int MoneyMarketAccount::getNumWithdrawals() const
{
return numWithdrawals;
}
int MoneyMarketAccount::withdraw(double amt)
{
if (amt < 0)
{
cout << "Attempt to withdraw negative amount - program terminated."<< endl;
exit(1);
}
if((numWithdrawals < FREE_WITHDRAWALS) && (amt <= acctBalance)){
acctBalance = acctBalance - amt;
return OK;
}
if((numWithdrawals >= FREE_WITHDRAWALS) &&((amt + WITHDRAWAL_FEE) <= acctBalance)){
acctBalance = acctBalance - (amt + WITHDRAWAL_FEE);
return OK;
}
return INSUFFICIENT_FUNDS;
}
// Defination of CDAccount CLASS
CDAccount::CDAccount(string name, double balance, double rate)
{
acctName = name;
acctBalance = balance;
interestRate = rate/100.0;
}
int CDAccount::withdraw(double amt)
{
if (amt < 0)
{
cout << "Attempt to withdraw negative amount - program terminated."<< endl;
exit(1);
}
double penalty = (PENALTY*interestRate*acctBalance);
if((amt + penalty) <= acctBalance){
acctBalance = acctBalance - (amt + penalty);
return OK:
}
else
return INSUFFICIENT_FUNDS;
}
void transfer (double amt, BankAccount& fromAcct, BankAccount& toAcct)
{
if (amt < 0 || fromAcct.acctBalance < 0 || toAcct < 0)
{
cout << "Attempt to transfer negative amount - program terminated."<< endl;
exit(1);
}
if(fromAcct.withdraw(amt) == OK){ // if withdraw function on fromAcct return OK, then me can withdraw amt from fromAcct
// and deposit in toAcct
toAcct.acctBalance = toAcct.acctBalance + amt;
}
}