Question

In: Computer Science

13. The class bankAccount stores a bank customer’s account number and balance. Suppose that account number...

13. The class bankAccount stores a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. This class provides the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information.

b. The class  checkingAccount from the class bankAccount (designed in part a). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. This class provides the following operations: set interest rate, retrieve interest rate, set minimum balance, retrieve minimum balance, set service charges, retrieve service charges, post interest, verify if the balance is less than the minimum balance, write a check, withdraw (override the method of the base class), and print account information.

c. Yours for definition and implementation :

Every bank offers a savings account. Derive the class savingsAccount from the class bankAccount (designed in part a). This class inherits members to store the account number and the balance from the base class. A customer with a savings account typically receives interest, makes deposits, and withdraws money. In addition to the operations inherited from the base class, this class should provide the following operations: set interest rate, retrieve interest rate, post interest, withdraw (override the method of the base class), and print account information. Add appropriate constructors.

d. Write a program to test your classes designed in parts c.

the program that needs to be edited is below thanks someone help these are the files I was given have to make changes

//Class bankAccount

#ifndef H_bankAccount
#define H_bankAccount

class bankAccount
{
public:
   void setAccountNumber(int acct);
   int getAccountNumber() const;
   double getBalance() const;
   void withdraw(double amount);
   void deposit(double amount);
   void print() const;
   bankAccount(int acctNumber = -1, double bal = 0);

protected:
   int accountNumber;
   double balance;
};

#endif

//Class checkingAccount

#ifndef H_checkingAccount
#define H_checkingAccount

#include "bankAccount.h"

const double DEFAULT_INTEREST_RATE_CHECKING = 0.04;
const double DEFAULT_MIN_BALANCE = 500.00;
const double DEFAULT_SERVICE_CHARGE = 20;

class checkingAccount : public bankAccount
{
public:
   double getMinimumBalance() const;
   void setMinimumBalance(double minBalance);
   double getInterestRate() const;
   void setInterestRate(double intRate);
   double getServiceCharge() const;
   void setServiceCharge(double intRate);
   void postInterest();
   bool verifyMinimumumBalance(double amount);
   void writeCheck(double amount);
   void withdraw(double amount);
   void print() const;

   checkingAccount(int acctNumber, double bal,
       double minBal = DEFAULT_MIN_BALANCE,
       double intRate = DEFAULT_INTEREST_RATE_CHECKING,
       double servC = DEFAULT_SERVICE_CHARGE);

protected:
   double interestRate;
   double minimumBalance;
   double serviceCharge;
};

#endif

//Implementation file bankAccountImp.cpp

#include <iostream>
#include <iomanip>
#include "bankAccount.h"

using namespace std;

bankAccount::bankAccount(int acctNumber, double bal)
{
   accountNumber = acctNumber;
   balance = bal;
}

void bankAccount::setAccountNumber(int acct)
{
   accountNumber = acct;
}

int bankAccount::getAccountNumber() const
{
   return accountNumber;
}

double bankAccount::getBalance() const
{
   return balance;
}

void bankAccount::withdraw(double amount)
{
   balance = balance - amount;
}

void bankAccount::deposit(double amount)
{
   balance = balance + amount;
}

void bankAccount::print() const
{
   cout << fixed << setprecision(2);
   cout << accountNumber << " balance : $"
       << balance << endl;
}

//Implementation file checkingAccountImp.cpp

#include <iostream>
#include <iomanip>
#include "checkingAccount.h"

using namespace std;

checkingAccount::checkingAccount(int acctNumber, double bal,
   double minBal, double intRate, double servC)
   : bankAccount(acctNumber, bal)
{
   interestRate = intRate;
   minimumBalance = minBal;
   serviceCharge = servC;
}

double checkingAccount::getMinimumBalance() const
{
   return minimumBalance;
}

void checkingAccount::setMinimumBalance(double minBalance)
{
   minimumBalance = minBalance;
}

double checkingAccount::getInterestRate() const
{
   return interestRate;
}

void checkingAccount::setInterestRate(double intRate)
{
   interestRate = intRate;
}

double checkingAccount::getServiceCharge() const
{
   return serviceCharge;
}

void checkingAccount::setServiceCharge(double servC)
{
   serviceCharge = servC;
}

void checkingAccount::postInterest()
{
   balance = balance + balance * interestRate;
}

bool checkingAccount::verifyMinimumumBalance(double amount)
{
   return (balance - amount >= minimumBalance);
}

void checkingAccount::writeCheck(double amount)
{
   withdraw(amount);
}

void checkingAccount::withdraw(double amount)
{
   if (balance - amount < 0)
       cout << "Not enough money in the account." << endl;
   else if (balance - amount < minimumBalance)
   {
       if (balance - amount - serviceCharge < minimumBalance)
       {
           cout << "After this transaction, the balanace will be "
               << "below the minimum balance." << endl
               << "However account does not have enough money "
               << "to process the transaction and apply service charge." << endl
               << "Transaction denied!" << endl;
       }
       else
       {
           cout << "After this transaction, the balanace will be "
               << "below the minimum balance." << endl
               << "Service charges will apply." << endl;

           balance = balance - amount - serviceCharge;
       }
   }
   else
       balance = balance - amount;
}

void checkingAccount::print() const
{
   cout << fixed << setprecision(2);
   cout << "Interest Checking ACCT#:\t" << getAccountNumber()
       << "\tBalance: $" << getBalance() << endl;
}


#include <iostream>
#include <iomanip>
//#include "savingsAccount.h"
#include "checkingAccount.h"

using namespace std;

int main()
{
   int accountNumber = 1000;

   checkingAccount jackAccount(accountNumber++, 1000);
   checkingAccount lisaAccount(accountNumber++, 450);
   //savingsAccount samirAccount(accountNumber++, 9300);
   //savingsAccount ritaAccount(accountNumber++, 32);

   jackAccount.deposit(1000);
   lisaAccount.deposit(2300);
   //samirAccount.deposit(800);
   //ritaAccount.deposit(500);

   jackAccount.postInterest();
   lisaAccount.postInterest();
   //samirAccount.postInterest();
   //ritaAccount.postInterest();

   cout << "***********************************" << endl;
   jackAccount.print();
   lisaAccount.print();
   //samirAccount.print();
   //ritaAccount.print();
   cout << "***********************************" << endl << endl;

   jackAccount.writeCheck(250);
   lisaAccount.writeCheck(350);
   //samirAccount.withdraw(120);
   //ritaAccount.withdraw(290);

   cout << "********After withdrawals ***************" << endl;
   jackAccount.print();
   lisaAccount.print();
   //samirAccount.print();
   //ritaAccount.print();
   cout << "***********************************" << endl << endl;

   return 0;
}

Solutions

Expert Solution

********************************************Summary**********************************************

The program files for above question are given below with the essential comments and the output....

However in the savings Account class i have assigned the interest rate as 0.02 ..you can change it in the savingsAccount.h file if you want.......

I hope it works for you!!!!!!!!!!!!!!!!!!!!

********************************************Program**********************************************

#1.savingsAccount.h

//Class savingsAccount

#ifndef H_savingsAccount
#define H_savingsAccount

#include "bankAccount.h"

const double DEFAULT_INTEREST_RATE_SAVINGS = 0.02;          //setting default interest rate  value

class savingsAccount:public bankAccount           //savingsAccount class inherting bankAccount class
{
public:
     void setInterestRate(double intRate);        //setInterest() function
     double getInterestRate() const;                        //retieve Interest function
     void postInterest();                         //post Interest() function
     void withdraw(double amount);                //overriding withdraw function of bankAccount
     void print() const;                          //printing account info
     
     savingsAccount(int acctNumber, double bal,             //appropriate constructor
       double intRate = DEFAULT_INTEREST_RATE_SAVINGS);
       
protected:
   double interestRate;            //member variable for storing interest rate
};

#endif

#2.savingsAccountImp.cpp

//Implementation file savingAccountImp.cpp

#include <iostream>
#include <iomanip>
#include "savingsAccount.h"

using namespace std;

savingsAccount::savingsAccount(int acctNumber, double bal, double intRate)
   : bankAccount(acctNumber, bal)            //calling construcotr of super class and setting interestRate=default interestRate
{
   interestRate = intRate;
}

void savingsAccount::setInterestRate(double intRate)        //setting new interest rate
{
   interestRate = intRate;
}

double savingsAccount::getInterestRate() const              //retriving interest rate
{
   return interestRate;
}

void savingsAccount::postInterest()               //adding interest to the balance
{
   balance = balance + balance * interestRate;
}

void savingsAccount::withdraw(double amount)      //withdrawing money from the account balance
{
   if (balance - amount < 0)
       cout << "Not enough money in the account." << endl;
   else
       balance = balance - amount;
}

void savingsAccount::print() const                //printing the account information
{
   cout << fixed << setprecision(2);
   cout << "Interest Checking ACCT#:\t" << getAccountNumber()
       << "\tBalance: $" << getBalance() << endl;
}

#3. main.cpp

#include <iostream>
#include <iomanip>
#include "savingsAccount.h"
#include "checkingAccount.h"

using namespace std;

int main()
{
   int accountNumber = 1000;

   checkingAccount jackAccount(accountNumber++, 1000);
   checkingAccount lisaAccount(accountNumber++, 450);
   savingsAccount samirAccount(accountNumber++, 9300);      //creating savingsaccount with balance 9300
   savingsAccount ritaAccount(accountNumber++, 32);              //creating savings account with balance 32

   jackAccount.deposit(1000);
   lisaAccount.deposit(2300);
   samirAccount.deposit(800);      //depositing amount in the account
   ritaAccount.deposit(500);

   jackAccount.postInterest();
   lisaAccount.postInterest();
   samirAccount.postInterest();         //adding the interest in the account balance
   ritaAccount.postInterest();

   cout << "***********************************" << endl;
   jackAccount.print();
   lisaAccount.print();
   samirAccount.print();      //printing account info before withdrawl
   ritaAccount.print();
   cout << "***********************************" << endl << endl;

   jackAccount.writeCheck(250);
   lisaAccount.writeCheck(350);
   samirAccount.withdraw(120);          //withdrawing amount from the account balance
   ritaAccount.withdraw(290);

   cout << "********After withdrawals ***************" << endl;
   jackAccount.print();
   lisaAccount.print();
   samirAccount.print();      //printing account info after withdrawl
   ritaAccount.print();
   cout << "***********************************" << endl << endl;

   return 0;
}

********************************************Output**********************************************

Output with code screenshot


Related Solutions

a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class...
In C++, define the class bankAccount to implement the basic properties of a bank account. An...
In C++, define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 components of type bankAccount to...
Write a program to create a bank account and to process transactions. Call this class bankAccount...
Write a program to create a bank account and to process transactions. Call this class bankAccount A bank account can only be given an initial balance when it is instantiated. By default, a new bank account should have a balance of 0. A bank account should have a public get method, but no public set method. A bank account should have a process method with a double parameter to perform deposits and withdrawals. A negative parameter represents a withdrawal. It...
1.   Design a class called BankAccount. The member fields of the class are: Account Name, Account...
1.   Design a class called BankAccount. The member fields of the class are: Account Name, Account Number and Account Balance. There are also other variables called MIN_BALANCE=9.99, REWARDS_AMOUNT=1000.00, REWARDS_RATE=0.04. They look like constants, but for now, they are variables of type double Here is the UML for the class:                                                         BankAccount -string accountName // First and Last name of Account holder -int accountNumber // integer -double accountBalance // current balance amount + BankAccount()                     //default constructor that sets name to “”,...
We plan to develop customer’s database that stores customer’s number (ID), first name, last name and...
We plan to develop customer’s database that stores customer’s number (ID), first name, last name and balance. The program will support three operations: (a) reading and loading customer’s info from the text file, (b) entering new customer’s info, (c) looking up existing customer’s info using customer’s number(ID), (d) deleting the customer’s info and (e) the updated database will be stored in the text file after the program terminate. Customer’s database is an example of a menu-driven program. When the program...
Write a class to keep track of a balance in a bank account with a varying...
Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the interest rate to some initial values (with defaults of zero). The class should have member functions to change or retrieve the current balance or interest rate. There should also be functions to make a deposit (add to the balance) or withdrawal (subtract from the balance). You should not allow more money to...
Write a class to keep track of a balance in a bank account with a varying...
Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the interest rate to some initial values (with defaults of zero). The class should have member functions to change or retrieve the current balance or interest rate. There should also be functions to make a deposit (add to the balance) or withdrawal (subtract from the balance). You should not allow more money to...
Create a class BankAccount to hold at least the following data / information about a bank...
Create a class BankAccount to hold at least the following data / information about a bank account: Account balance Total number of deposits Total number of withdrawals Interest rate e.g., annual rate = 0.05 Service charges per month The class should have the following member functions: Constructor To set the required data. It may be parameterized or user’s input. depositAmount A virtual function used to accept an argument for the amount to be deposited. It should add the argument (amount)...
Write in Java the following: A.  A bank account class that has three protected attributes: account number...
Write in Java the following: A.  A bank account class that has three protected attributes: account number (string), customer name (string), and balance (float). The class also has a parameterized constructor and a method public void withDraw (float amount) which subtracts the amount provided as a parameter from the balance. B. A saving account class that is a child class of the bank account class with a private attribute: penality rate (float). This class also has a parameterized constructor and a...
13.Suppose you deposit $5,000 into your bank account today. If the bank pays 3.75percent per year,...
13.Suppose you deposit $5,000 into your bank account today. If the bank pays 3.75percent per year, then which of the following statements is (are) correct? (x)$7,825.14is in your account after 12years if interest is compounded quarterly but only $7,777.27if the interest is compounded annually.(y)You will earn an additional $31.69of interest in your account after 12years if interest is compounded semi-annually instead of annually, but $27.10less interest if interest is compounded semi-annually instead of monthly.(z)Although compounding daily instead of weekly will...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT