Monday, 25 December 2017

Bank Account Hierarchy


1. ADT: Account
Design an Account class that has the following members:
Protected Member Variable:
firstName, a string used to hold the first name of the account holder.
lastName, a string used to hold the last name of the account holder.
curBalance, a double used to hold the current balance of the account holder.
Public Member Functions:
• Account(const string& fname, const string &lname, double curbalance);
• virtual string getAcctType() const;
Returns "Account" (and that's all it does).
• virtual double bebitTransaction(double debitamount);
Subtract the transaction amount from the account. No condition check is required.
• virtual double creditTransaction(double creditamount);
Add the transaction amount to the account. No condition check is required.
• void print(ostream& os);
Print the three fields to the parameter ostream. The fields must be printed in a formatted way, in a fixed-size column
and appropriate left/right justification for each field as below.
Saud, Yaseen CheckingAccount 200.00
Hunain, Shahid SavingsAccount 1000.00
2. ADT: CheckingAccount
Minimum balance on the account is equal to 100. For every transaction resulting in the amount of the account being lower
than the minimum balance, a transaction fee of 10 is charged. The balance can become negative.
Design a CheckingAccount class that is derived from the Account class. The CheckingAccount class should have the following
members:
Public Member Functions:
• CheckingAccount(const string& fname, const string& lname, double curbalance);
Do not forget to initialize fields other than the three parameters.
• virtual string getAcctType() const;
Returns "CheckingAccount" (and that's all it does).
• virtual double debitTransaction(double debitamount);
Subtracts the transaction amount from the account and possibly charges a transaction fee. You must call the base
class debitTransaction() method inside this method.
• virtual double creditTransaction(double creditamount);
Adds the transaction amount to the account and possibly charges a transaction fee. You must call the base class
creditTransaction() method inside this method.
• void chargeFee();
This is a private method. It is called internally by the debit and credit transaction methods.

3. ADT: SavingsAccount
A maximum of 2 transactions is allowed. After successfully committing any transaction an interest of 2% is paid (i.e., added
to the current balance). The interest is paid on the entire amount of the account.
Design a SavingsAccount class that is derived from the Account class. The SavingsAccount class should have the following
members:
Public Member Functions:
• SavingsAccount(const string& fname, const string& lname, double curbalance);
Do not forget to initialize fields other than the three parameters.
• virtual string getAcctType() const;
Returns "SavingsAccount" (and that's all it does).
• virtual double debitTransaction(double debitamount);
If there are less than two transactions, subtracts the transaction amount from the account and pays interest. You
must call the base class debitTransaction() method inside this method.
• virtual double creditTransaction(double creditamount);
If there are less than two transactions, adds the transaction amount to the account and pays interest. You must call
the base class creditTransaction() method inside this method.
• void payInterest();
This is a private method. It is called internally by the debit and credit transaction methods.
4. Main Function
This application program uses the classes you have developed. It creates one Checking account and one Savings account, and
does some transactions. After every transaction, the account information is displayed, by calling print(cout) in the object.
Requirements:
1. Both objects must be dynamically created and pointed by the base class pointer. For example,
Account* c = new CheckingAccount("Osama", "Jameel", 100.0);

code link .....
https://www.dropbox.com/s/xd12zkzc8wa8q4f/Bank%20Account.cpp?dl=0

No comments:

Post a Comment

ADT: RationalNumber

Define a class for rational numbers. A rational number is “ratio-nal” number, composed of two integers with division indicated. The division...