Question#3: a polymorphic banking program. Develop a polymorphic banking program
ID: 3553923 • Letter: Q
Question
Question#3:
a polymorphic banking program.
Develop a polymorphic banking program using the Account hierarchy by create an inheritance hierarchy that a bank might use to represent customers bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base class Account and derived classes Savings-Account and Checking-Account that inherit from class Account.
// Account.h
// Definition of Account class.
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account
{
public:
Account( double );
/* Write a function prototype for virtual function credit */
/* Write a function prototype for virtual function debit */
void setBalance( double );
double getBalance();
private:
double balance; };
#endif
// Account.cpp
// Member-function definitions for class Account.
#include <iostream>
using std::cout;
using std::endl;
#include "Account.h"
Account::Account( double initialBalance ){
if ( initialBalance >= 0.0 )
balance = initialBalance;
else {
cout << "Error: Initial balance cannot be negative." << endl;
balance = 0.0;
}
} // end Account constructor
void Account::credit( double amount ){
balance = balance + amount; } // end function credit
bool Account::debit( double amount ) {
if ( amount > balance ) {
cout << "Debit amount exceeded account balance." << endl;
return false;
} // end if
else {
balance = balance - amount;
return true;
} // end else
} // end function debit
void Account::setBalance( double newBalance ) {
balance = newBalance;
} // end function setBalance
double Account::getBalance() {
return balance;
} // end function getBalance
double interestRate;
SavingsAccount( double, double );
double transactionFee;
CheckingAccount( double, double );
Explanation / Answer
Do find the complete work here : https://drive.google.com/#folders/0B5e1-GnoHVpBU3RCS3dUUHVvSVE
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.