Question

Introduction Extend the inheritance hierarchy from the previous project by changing the classes to template classes....

Introduction
Extend the inheritance hierarchy from the previous project by changing the classes to template classes. Do
not worry about rounding in classes that are instantiated as integer classes, you may just use the default
rounding. You will add an additional data member, method, and bank account type that inherits SavingsAc-count ("CD", or certicate of deposit).

Deliverables
A driver program (driver.cpp)
An implementation of Account class (account.h)
An implementation of SavingsAccount (savingsaccount.h)
An implementation of CheckingAccount (checkingaccount.h)
An implementation of CDAccount (cdaccount.h)

1 Account class
Change to a template class and add/modify the following items.
1.1 Data Members
accountNumber (string)
1.2 Member Functions
Constructors
Add accountNumber to the constructor.
Accessors
string getAccountNumber() Returns the account number.
void displayAccount() Prints the account type, fee or interest rate, and balance. Determine if this
should be virtual, pure virtual, or regular.

2 SavingsAccount class
Change to a template class. Add accountNumber to the constructor. You may make interestRate `protected'
so you can directly access it in CDAccount. No other modi cations.

3 CheckingAccount class
Change to a template class. Add accountNumber to the constructor. No other modi cations.

4 CDAccount class
Implement a template class that is derived from SavingsAccount class.

4.1 Data Members
No additional data members (inherits its data members).


Constructors
De nes a parameterized constructor which calls the SavingsAccount constructor.
Destructor
De nes destructor. If you have allocated memory, clean it up.
Mutators
void debit(amount) Rede nes the member function to debit nothing from the balance and return
false, since you are not allowed to debit from a CD during its term.
void credit(amount) Invokes the base class credit member function to add to the account.

5 The Driver Program
In your driver, prompt the user for input as shown below. Create two vectors (savingsAccounts and
checkingAccounts). The rst has Account pointers with type double that point to a CD and a Savings
account, the second has Account pointers with integer type and point to two Checking accounts. Initialize
the objects with the user's input and appropriate constructors.
Next, create a loop that, for each savingsAccount, allows the user to deposit and withdraw from the account
using the base class member functions. After withdrawing and depositing, downcast to a SavingsAccount
pointer and add interest. Print the updated information by invoking the base class member function dis-
playAccount().
Create another loop for each checkingAccount that allows the user to deposit and withdraw from the account
using the base class member functions. After withdrawing and depositing, print the updated information
by invoking the base class member function displayAccount(). Verify that, even if doubles are passed to the
constructor, their values are coerced to integers.


5.1 Example input:
CD Account 1
Please enter the account number: 98765432
Please enter the balance: 70
Please enter the interest rate: 0.1
(repeat for the savings account)
Checking Account 1
Please enter the account number: 01010101
Please enter the balance: 70.55
Please enter the fee: 1.99
(repeat for next checking account)

5.2 Example output:
CD Account 1 balance: $70.00
Enter an amount to withdraw from Account 1: 10.00
Cannot debit from a CD account.
Enter an amount to deposit into Account 1: 35.00
Adding $10.50 interest to Account 1
CD account 01234567 has an interest rate of 0.10 and a balance of $115.50
Checking Account 1 balance: $70
Enter an amount to withdraw from Account 1: 9.99 0
$1 transaction fee charged
Enter an amount to deposit into Account 1: .99
$1 transaction fee charged.
Checking account 01010101 has a $1 transaction fee and a balance of $59

Files from previous project

driver.cpp

#include <iostream>

#include <iomanip>

#include <vector>

using namespace std;

#include "Account.h" // Account class definition

#include "SavingsAccount.h" // SavingsAccount class definition

#include "CheckingAccount.h" // CheckingAccount class definition

int main() {

// create vector accounts

vector < Account * > accounts(6);

double balance1, balance2, balance3, balance4, balance5, balance6;

double rate1, rate2, rate3;

double fee1, fee2, fee3;

cout << "Enter balance and interest rate for account1:" << endl;

cin >> balance1;

cin >> rate1;

cout << "Enter balance and transaction fee for account2:" << endl;

cin >> balance2;

cin >> fee1;

cout << "Enter balance and interest rate for account3:" << endl;

cin >> balance3;

cin >> rate2;

cout << "Enter balance and transaction fee for account4:" << endl;

cin >> balance4;

cin >> fee2;

cout << "Enter balance and interest rate for account5:" << endl;

cin >> balance5;

cin >> rate3;

cout << "Enter balance and transaction fee for account6:" << endl;

cin >> balance6;

cin >> fee3;

// initialize vector with Accounts

accounts[0] = new SavingsAccount(balance1, rate1);

accounts[1] = new CheckingAccount(balance2, fee1);

accounts[2] = new SavingsAccount(balance3, rate2);

accounts[3] = new CheckingAccount(balance4, fee2);

accounts[4] = new SavingsAccount(balance5, rate3);

accounts[5] = new CheckingAccount(balance6, fee3);

cout << fixed << setprecision(2);

// loop through vector, prompting user for debit and credit amounts

for (size_t i = 0; i < accounts.size(); i++) {

cout << "Account " << i + 1 << " balance: $"

<< accounts[i]->getBalance();

double withdrawalAmount = 0.0;

cout << "\nEnter an amount to withdraw from Account " << i + 1

<< ": ";

cin >> withdrawalAmount;

accounts[i]->debit(withdrawalAmount); // debit account

double depositAmount = 0.0;

cout << "Enter an amount to deposit into Account " << i + 1

<< ": ";

cin >> depositAmount;

accounts[i]->credit(depositAmount); // credit account

// downcast pointer

SavingsAccount *savingsAccountPtr = dynamic_cast < SavingsAccount * > (accounts[i]);

// if Account is a SavingsAccount, calculate and add interest

if (savingsAccountPtr != 0) {

double interestEarned = savingsAccountPtr->calculateInterest();

cout << "Adding $" << interestEarned << " interest to Account "

<< i + 1 << " (a SavingsAccount)" << endl;

savingsAccountPtr->credit(interestEarned);

} // end if

cout << "Updated Account " << i + 1 << " balance: $"

<< accounts[i]->getBalance() << "\n\n";

} // end for

system("pause");

} // end main

savingsaccount.h

#ifndef SAVINGS_H

#define SAVINGS_H

#include "Account.h" // Account class definition

class SavingsAccount : public Account {

public:

// constructor initializes balance and interest rate

SavingsAccount(double, double);

double calculateInterest(); // determine interest owed

private:

double interestRate; // interest rate (percentage) earned by account

}; // end class SavingsAccount

#endif

savingsaccount.cpp

#include "SavingsAccount.h" // SavingsAccount class definition

// constructor initializes balance and interest rate

SavingsAccount::SavingsAccount(double initialBalance, double rate)

: Account(initialBalance) {// initialize base class

interestRate = (rate < 0.0) ? 0.0 : rate; // set interestRate

} // end SavingsAccount constructor

// return the amount of interest earned

double SavingsAccount::calculateInterest() {

return getBalance() * interestRate;

} // end function calculateInterest

checkingaccount.h

#ifndef CHECKING_H

#define CHECKING_H

#include "Account.h" // Account class definition

class CheckingAccount : public Account {

public:

// constructor initializes balance and transaction fee

CheckingAccount(double, double);

/*function prototype for virtual function credit,

which will redefine the inherited credit function */

virtual void credit(double);

/*function prototype for virtual function debit,

which will redefine the inherited debit function */

virtual bool debit(double);

private:

double transactionFee; // fee charged per transaction

// utility function to charge fee

void chargeFee();

}; // end class CheckingAccount

#endif

checkingaccount.cpp

#include <iostream>

using namespace std;

#include "CheckingAccount.h" // CheckingAccount class definition

// constructor initializes balance and transaction fee

CheckingAccount::CheckingAccount(double initialBalance, double fee)

: Account(initialBalance) { // initialize base class

transactionFee = (fee < 0.0) ? 0.0 : fee; // set transaction fee

} // end CheckingAccount constructor

// credit (add) an amount to the account balance and charge fee

void CheckingAccount::credit(double amount) {

Account::credit(amount); // always succeeds

chargeFee();

} // end function credit

// debit (subtract) an amount from the account balance and charge fee

bool CheckingAccount::debit(double amount) {

bool success = Account::debit(amount); // attempt to debit

if (success) { // if money was debited, charge fee and return true

chargeFee();

return true;

} // end if

else // otherwise, do not charge fee and return false

return false;

} // end function debit

// subtract transaction fee

void CheckingAccount::chargeFee() {

Account::setBalance(getBalance() - transactionFee);

cout << "$" << transactionFee << " transaction fee charged." << endl;

} // end function chargeFee

account.h

#ifndef ACCOUNT_H

#define ACCOUNT_H

class Account {

public:

Account(double); // constructor initializes balance

virtual void credit(double); // function prototype for virtual function credit

virtual bool debit(double); // function prototype for virtual function debit

void setBalance(double); // sets the account balance

double getBalance(); // return the account balance

private:

double balance; // data member that stores the balance

}; // end class Account

#endif

account.cpp

#include <iostream>

using namespace std;

#include "Account.h" // include definition of class Account

// Account constructor initializes data member balance

Account::Account(double initialBalance) {

// if initialBalance is greater than or equal to 0.0, set this value

// as the balance of the Account

if (initialBalance >= 0.0)

balance = initialBalance;

else { // otherwise, output message and set balance to 0.0

cout << "Error: Initial balance cannot be negative." << endl;

balance = 0.0;

} // end if...else

} // end Account constructor

// credit (add) an amount to the account balance

void Account::credit(double amount) {

balance = balance + amount; // add amount to balance

} // end function credit

// debit (subtract) an amount from the account balance

// return bool indicating whether money was debited

bool Account::debit(double amount) {

if (amount > balance) { // debit amount exceeds balance

cout << "Debit amount exceeded account balance." << endl;

return false;

} // end if

else { // debit amount does not exceed balance

balance = balance - amount;

return true;

} // end else

} // end function debit

// set the account balance

void Account::setBalance(double newBalance) {

balance = newBalance;

} // end function setBalance

// return the account balance

double Account::getBalance() {

return balance;

} // end function getBalance

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following information has been provided for the question above:

  • "Screen shot of C++ code" for your understanding.
  • "Text format code" to copy and execute in your IDE.

Screen shot of C++ code:

Output:

Text format code:


//A driver program (driver.cpp)
//Header file section
#include<iostream>
#include<vector>
#include<string>
#include "Account.h"
#include "SavingsAccount.h"
#include "CheckingAccount.h"
#include "CDAccount.h"
using namespace std;
//Program begins with a main function
int main()
{
//Declare variables
double balance = 0.0, fee = 0.0, interestRate = 0.0;
double amount = 0.0;
string acctNumber;

// Define a vector of type Account, saveOrCDAccount
vector <Account<double> *> saveOrCDAccount;

// Define a vector of type Account,checkAccount
vector <Account<int> *> checkAccount;

// Prompt the user for the CDAccount details
cout << "\nCD Account 1\n";

//Prompt and read the input from the user
cout << "Please enter the account number: ";
cin.ignore();
getline(cin, acctNumber);
cout << "Please enter the balance: ";
cin >> balance;
cout << "Please enter the interest rate: ";
cin >> interestRate;
// Define the CDAccount object
saveOrCDAccount.push_back(new CDAccount<double>(balance, interestRate, acctNumber));

//Prompt and read the input from the user
cout << "\nSavings Account\n";
cout << "Please enter the account number: ";
cin.ignore();
getline(cin, acctNumber);
cout << "Please enter the balance: ";
cin >> balance;
cout << "Please enter the interest rate: ";
cin >> interestRate;
// Define the Savings Account object
saveOrCDAccount.push_back(new SavingsAccount<double>(balance, interestRate, acctNumber));
// prompt the user for the Checking Account details
cout << "\nChecking Account 1\n";

//Prompt and read the input from the user
cout << "Please enter the account number: ";
cin.ignore();
getline(cin, acctNumber);
cout << "Please enter the balance: ";
cin >> balance;
cout << "Enter the fee: ";
cin >> fee;
// Define the Checking account object
checkAccount.push_back(new CheckingAccount<int>(balance, fee, acctNumber));
//Prompt and read the input from the user
cout << "\nChecking Account 2\n";
cout << "Please enter the account number: ";
cin.ignore();
getline(cin, acctNumber);
cout << "Please enter the balance: ";
cin >> balance;
cout << "Enter the fee: ";
cin >> interestRate;
// Define the Checking account object
checkAccount.push_back(new CheckingAccount<int>(balance, fee, acctNumber));
// Perform the withdraw and deposit operations on saveOrCDAccount
cout << "\nOperations with Savings or CD account " << endl;
for (int i = 0; i < saveOrCDAccount.size(); i++)
{
  cout << endl;
  if (i % 2 == 0)
  {
   cout << "CD Account"<<(i+1)<<" balance:$ "
    << saveOrCDAccount[i]->getBalance() << endl;
   cout << "Enter an amount to withdraw from Account"<< (i+1)<<":";
   cin >> amount;
   if (!((CDAccount<double> *)saveOrCDAccount[i])
    ->debit(amount))
   {
    cout << "Cannot debit from a CD account.\n";
   }
   cout << "Enter an amount to deposit into CD Account" << (i+1) << ":";
   cin >> amount;
   saveOrCDAccount[i]->credit(amount);
   interestRate = ((CDAccount<double> *)saveOrCDAccount[i])
    ->calcInterest();
   saveOrCDAccount[i]->credit(interestRate);
   cout << "Adding $" << interestRate
   << " interest to Account"<<(i+1)<< endl;
  }
  else
  {
   cout << "Savings Account balance:$ "
    << saveOrCDAccount[i]->getBalance() << endl;
   cout << "Enter an amount to withdraw from Savings Account"<<(i+1)<<":";
   cin >> amount;
   if (!((SavingsAccount<double> *)saveOrCDAccount[i])
    ->debit(amount))
   {
    cout << "Cannot debit from a savings account.\n";
   }
   cout << "Enter an amount to deposit into Savings Account: ";
   cin >> amount;
   saveOrCDAccount[i]->credit(amount);
   interestRate = ((SavingsAccount<double> *)
    saveOrCDAccount[i])->calcInterest();
   saveOrCDAccount[i]->credit(interestRate);
   cout << "Adding " << interestRate
    << " interest to Savings Account " << endl;
  }
  saveOrCDAccount[i]->displayAccount();
}
// Perform the withdraw and deposit operations on checkAccount
cout << "\nOperations with Checking account " << endl;
for (int i = 0; i < checkAccount.size(); i++)
{
  cout << endl;
  cout << "Checking Account " << (i + 1) << " balance: " <<
   checkAccount[i]->getBalance() << endl;
  cout << "Enter an amount to withdraw from Account " << (i + 1) << ": ";
  cin >> amount;
  if (!((CheckingAccount<int> *)checkAccount[i])->debit(amount))
  {
   cout << "Cannot debit from a Checking account.\n";
  }
  //Prompt and read the input from the user
  cout << "Enter an amount to deposit into Account " << (i + 1) << ": ";
  cin >> amount;
  //call the methods
  checkAccount[i]->credit(amount);
  checkAccount[i]->displayAccount();
}
cout << endl;
//Pause the system for a while
system("pause");
return 0;
}

//Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

// Account class of type template holds the
// balance and account number
template<class T>
class Account
{

// class variables
private:

T balance;
string accountNumber;
// member functions
public:
// constuctor
Account();
// parameterized constructor
Account(T amount, string accountNumber);
//methods
T getBalance();
void setBalance(T amount);
string getAccountNumber();
virtual void displayAccount();
virtual bool debit(T amount);
virtual void credit(T amount);

// destructor

~Account();

};
// definitions of member functions
// default constructor
template<class T>
Account<T>::Account()
{
balance = 0.0;
accountNumber = " ";
}
// depending on the amount value, set the amount
// and account number accordingly
template<class T>
Account<T>::Account(T amount, string accountNumber)
{
if (amount < 0)
{
  balance = 0.0;
  cout << "Balance cannot be less than 0" << endl;
}
else
{
  balance = amount;
}
this->accountNumber = accountNumber;
}
// this returns the balance of T type
template<class T>
T Account<T>::getBalance()
{
return balance;
}
// this returns the accountNumber as string
template<class T>
string Account<T>::getAccountNumber()
{
return this->accountNumber;
}
// Implement the method debit from the initial amount
template<class T>
bool Account<T>::debit(T amount)
{
if (amount > balance)
{
  cout << "Cannot debit $" << amount << ". Insufficient balance.";
  return false;
}
else
{
  balance -= amount;
  return true;
}
}
// Method definition of credit
template<class T>
void Account<T>::credit(T amount)
{
balance += amount;
}
// Method definition of setBalance
template<class T>
void Account<T>::setBalance(T newBalance)
{
balance = newBalance;
}
// destructor
template<class T>
Account<T>::~Account()
{
delete this;
}
// Method definition of displayAccount
template<class T>
void Account<T>::displayAccount()
{
cout << setprecision(2) << fixed;
cout << "Account Number : " << this->accountNumber << endl;
cout << "Balance: $" << this->balance << endl;
}
#endif


//SavingsAccount.h
#ifndef SAVINGSACCOUNT_H
#define SAVINGSACCOUNT_H
#include "Account.h"
#include <iostream>
#include <string>
using namespace std;
// SavingsAccount is a template class which is derived
// from the account class.
template<class T>
class SavingsAccount : public Account<T>
{

// member variable
protected:

T interestRate;
// member functions

public:

// default contructor
SavingsAccount();

// parameterized constructor
SavingsAccount(T balance, T interest, string accountnumber);
// destructor
~SavingsAccount();
// methods
T calcInterest();
virtual void displayAccount();
bool debit(T amount);
void credit(T amount);
};
// default constructor
template<class T>
SavingsAccount<T>::SavingsAccount() : Account<T>()
{
interestRate = 0.0;
}
// parameterized constructor
template<class T>
SavingsAccount<T>::SavingsAccount(T balance, T interest,
string accountnumber) : Account<T>(balance, accountnumber)
{

interestRate = (interest < 0.0) ? 0.0 : interest;
}
// Method definition of calcInterest
template<class T>
T SavingsAccount<T>::calcInterest()
{
return interestRate * getBalance();
}
// Method definition of SavingsAccount
template<class T>
SavingsAccount<T>::~SavingsAccount()
{
delete this;
}
// Method definition of debit
template<class T>
bool SavingsAccount<T>::debit(T amount)
{
return Account::debit(amount);
}
// Method definition of credit
template<class T>
void SavingsAccount<T>::credit(T amount)
{

Account::credit(amount);

}
// method to display the account information
template<class T>
void SavingsAccount<T>::displayAccount()
{
cout << setprecision(2) << fixed;
cout << "Savings account " << getAccountNumber()
  << " has an interest rate of " << interestRate
  << " and a balance of $" << getBalance() << endl;
}

#endif

//CheckingAccount.h
//Headere file section
#ifndef CHECKINGACCOUNT_H
#define CHECKINGACCOUNT_H
#include "Account.h"
#include <iostream>
#include <string>
using namespace std;
template <class T>
class CheckingAccount : public Account<T>
{
//Declare variables
private:
T feeForTransaction;
void chargeFee();

public:

// default constuctor
CheckingAccount();

// parameterized constructor
CheckingAccount(T balance, T fee, string accountnumber);

//methods
void setTransactionFee(T fee);
T getTransactionFee();
virtual bool debit(T amount);
virtual void credit(T amount);
void displayAccount();
~CheckingAccount();

};
// Default constructor

template<class T>
CheckingAccount<T>::CheckingAccount() : Account<T>()
{
feeForTransaction = 0.0;
}
// parameterized constructor
template<class T>
CheckingAccount<T>::CheckingAccount(T balance, T fee, string accountnumber)
: Account<T>(balance, accountnumber)
{
if (fee >= 0.0)
{
  feeForTransaction = fee;
}
else
{
  cout << "Error. Fee cannot be negative." << endl;
  feeForTransaction = 0.0;
}
}
// to set the transaction fee
template<class T>
void CheckingAccount<T>::setTransactionFee(T fee)
{
this->feeForTransaction = fee;
}
// to retrieve the transaction fee
template<class T>
T CheckingAccount<T>::getTransactionFee()
{
return feeForTransaction;
}
// destructor that removes the existing class object
template<class T>
CheckingAccount<T>::~CheckingAccount()
{
delete this;
}
// Implement the method debit from the initial amount
template<class T>
bool CheckingAccount<T>::debit(T amount)
{
if (amount < getBalance())
{
  chargeFee();
  return Account<T>::debit(amount);
}
else
{
  cout << "Cannot debit. Insufficient balance." << endl;
  return false;
}
}
// Implement the method credit from the initial amount
template<class T>
void CheckingAccount<T>::credit(T amount)
{
if ((amount + this->getBalance()) >= feeForTransaction)
{
  Account<T>::credit(amount);
  chargeFee();
}
else
{
  cout << "Cannot credit. Insufficient balance" << endl;
}
}
// method to display the account information
template<class T>
void CheckingAccount<T>::displayAccount()
{
cout << "Checking account " << getAccountNumber()
  << " has a transaction fee " << feeForTransaction
  << " and a balance of $" << getBalance() << endl;
}
// method to apply the chargeFee
template<class T>
void CheckingAccount<T>::chargeFee()
{
Account<T>::setBalance(getBalance() - feeForTransaction);
cout << "$" << feeForTransaction << " transaction fee charged" << endl;
}
#endif

//CDAccount.h
//Header file section
#ifndef CDACCOUNT_H
#define CDACCOUNT_H
#include "SavingsAccount.h"
#include <iostream>
#include <string>
using namespace std;
// CDAccount class of type Template derieved from the
// SavingsAccount
template<class T>
class CDAccount : public SavingsAccount<T>
{
// Member functions
public:
// Constructor
CDAccount();

// Parameterized constructor
CDAccount(T balance, T interest, string accountnumber);
// desturctor
~CDAccount();
//methods
bool debit(T amount);
void credit(T amount);
void displayAccount();
};

// constructor
template<class T>
CDAccount<T>::CDAccount() : SavingsAccount<T>()
{
interestRate = 0.0;
}
// parameterized constructor
template<class T>
CDAccount<T>::CDAccount(T balance, T interest, string accountnumber)
: SavingsAccount<T>(balance, interest, accountnumber)
{

}
// destructor
template<class T>
CDAccount<T>::~CDAccount()
{
delete this;
}
// Method definition of debit
template<class T>
bool CDAccount<T>::debit(T amount)
{
return false;
}

// Method definition of credit
template<class T>
void CDAccount<T>::credit(T amount)
{
Account::credit(amount);
}
// Method definition of displayAccount
template<class T>
void CDAccount<T>::displayAccount()
{
cout << setprecision(2) << fixed;
cout << "CD account " << getAccountNumber()
  << " has an interest rate of " << interestRate
  << " and a balance of $" << getBalance() << endl;
}
#endif

Add a comment
Know the answer?
Add Answer to:
Introduction Extend the inheritance hierarchy from the previous project by changing the classes to template classes....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MAIN OBJECTIVE       Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture...

    MAIN OBJECTIVE       Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture an output. polymorphism. Write an application that creates a vector of Account pointers to two SavingsAccount and two CheckingAccountobjects. For each Account in the vector, allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account, determine its...

  • In C++ 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.,...

    In C++ 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...

  • (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account...

    (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account in the vector, allow the user to specify an amount of money to withdraw from the Bank-Account using member function debit and an amount of money to deposit into the Bank-Account using member function credit. As you process each Bank-Account, determine its type. If a Bank-Account is a Savings, calculate the amount of interest owed to the Bank-Account using member function calculateInterest,...

  • C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money...

    C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings and checking. Each of these accounts has various options. For example, you may have a savings account that requires no minimum balance but has a lower interest rate. Similarly, you may have a checking account that limits the number of checks you may write....

  • Please show it in C++. Thank you! Problem Definition Create an inheritance hierarchy containing base class...

    Please show it in C++. Thank you! Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial baiance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money...

  • question

    : Implement the following given scenario in C++ a. Create an inheritance hierarchy by writing the source code, containing base class BankAccount and derived classes SavingsAccount and CheckingAccount that inherit from class BankAccount. b. Implement Polymorphism where required to achieve the polymorphic behavior. c. Multiple constructors be defined for initializing the account of a user. d. The class should provide four member functions. i. Member function Credit should add an amount to the current balance. ii. Member function Debit should...

  • C++ Help. PLEASE include detailed comments and explanations. PLEASE follow the drections exactly. Thank you. Define...

    C++ Help. PLEASE include detailed comments and explanations. PLEASE follow the drections exactly. Thank you. Define a class with the name BankAccount and the following members: Data Members: accountBalance: balance held in the account interestRate: annual interest rate. accountID: unique 3 digit account number assigned to each BankAccount object. Use a static data member to generate this unique account number for each BankAccount count: A static data member to track the count of the number of BankAccount objects created. Member...

  • Im having trouble with this C++ program. Lab 10/object/test files provided LAB 10 1 //Savings.cpp - displays the account balance at 2 //the end of 1 through 3 years 3 //Created/revised by <your nam...

    Im having trouble with this C++ program. Lab 10/object/test files provided LAB 10 1 //Savings.cpp - displays the account balance at 2 //the end of 1 through 3 years 3 //Created/revised by <your name> on <current date> 4 5 #include <iostream> 6 #include <iomanip> 7 #include <cmath> 8 using namespace std; 9 10 //function prototype 11 double getBalance(int amount, double rate, int y); 12 13 int main() 14 { 15 int deposit = 0; 16 double interestRate = 0.0; 17...

  • Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’...

    Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this back 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. Create base class Account and derived classes SavingsAccount and CheckingAccount that inherit...

  • For this week's assignment , please create an application following directions in the attached document.(windows form...

    For this week's assignment , please create an application following directions in the attached document.(windows form application) Create a base class named Account and derived classes named SavingsAccount and CheckingAccount that inherit from class Account. Base class Account should include one private instance variable of type decimal to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the instance variable with a public property. The property should validate the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT