Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Banks have many different types of accounts, often with different rules forfees associated with transactions such as withdrawals. Customers areallowed to transfer funds between accounts incurring the...

1 answer below »
Banks have many different types of accounts, often with different rules forfees associated with transactions such as withdrawals. Customers areallowed to transfer funds between accounts incurring the appropriate feesassociated with withdrawal of funds from one account.Write a program with a base class for a bank account and two derivedclasses (as described below) representing accounts with different rules forwithdrawing funds. Also write a function that transfers funds from oneaccount (of any type) to another. A transfer is a withdrawal from oneaccount and a deposit into the other. Since the transfer can be done at anytime with any type of account, the withdraw function in the classes must bevirtual. Write a main program that creates three accounts (one from eachclass) and tests the transfer function.For the classes, create a base class called BankAccount that has the name ofthe owner of the account (a string) and the balance in the account (double)as data members. Include member functions deposit and withdraw (eachwith a double for the amount as an argument) and accessor functionsgetName and getBalance. Deposit will add the amount to the balance(assuming the amount is nonnegative) and withdraw will subtract theamount from the balance (assuming the amount is nonnegative and lessthan or equal to the balance). Also create a class calledMoneyMarketAccount that is derived from BankAccount. In aMoneyMarketAccount the user gets two free withdrawals in a given periodof time (don’t worry about the time for this problem). After the freewithdrawals have been used, a withdrawal fee of $1.50 is deducted from thebalance per withdrawal. Hence, the class must have a data member to keeptrack of the number of withdrawals. It also must override the withdrawdefinition. Finally, create a CDAccount class (to model a Certificate ofDeposit) derived from BankAccount that in addition to having the name andbalance also has an interest rate. CDs incur penalties for early withdrawalof funds. Assume that a withdrawal of funds (any amount) incurs a penaltyof 25% of the annual interest earned on the account. Assume the amountwithdrawn plus the penalty are deducted from the account balance. Again,the withdraw function must override the one in the base class. For all threeclasses, the withdraw function should return an integer indicating the status(either ok or insufficient funds for the withdrawal to take place). For thepurposes of this exercise, do not worry about other functions and propertiesof these accounts (such as when and how interest is paid).
Answered Same Day Nov 13, 2021

Solution

Arun Shankar answered on Nov 15 2021
139 Votes
#include #include using namespace std;
The base class
class BankAccount
{

Attributes
string name;
name of the owner
double balance;
balance amount

Functions
public:

Constructor
BankAccount(string a, double b)
{
name = a;
balance = b;
}

The virtual withdraw function

virtual int withdraw(double amount) = 0;
virtual int withdraw(double amount) {return 1;}

The deposit function
void deposit(double amount)
{
if(amount>0)
setBalance(balance+amount);
}

Accessor methods
string functionsgetName()
{
return name;
}
double getBalance()
{
return balance;
}

Mutator methods
void setBalance(double b)
{
balance = b;
}
};
Two derived classes
class MoneyMarketAccount :public BankAccount
{

How many withdrawals have you made ?
int count;
public:

Constructo
MoneyMarketAccount(string owner, double bal):BankAccount(owner, bal)
{

No withdrawals yet when the account is just created.
count = 0;
}

Definition of the virtual withdraw function
int withdraw(double amount)
{
if(amount<=0)
do nothing if the amount is <=0
return 0;
if(count>=2)
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here