Question

In: Computer Science

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) to the account balance. It should also increment the variable used to track the number of deposits.

withdrawAmount

A virtual function used to accept an argument for the withdraw amount operation. It should subtract the argument from the account balance. It should also increment the used to track the number of withdrawals.

calculateInterest

A virtual function which calculates the monthly interest of the account and then updates the account balance by adding it to the principal amount.

Note: Use the standard formulas/operations (monthly interest calculation) to implement this function.

monthlyProcessing

A virtual function which calls the calculateInterest function, subtracts the monthly service charges from the balance, and then sets the corresponding variables such as no. of withdrawals, no. of deposits, monthly service charges and so on.

getMonthlyStatistics

A member function used to display the monthly statistics of the account such as deposit, withdrawals, service charges, balance etc.

Next, create a SavingAccount class which is derived from the generic class BankAccount. It should at least have one additional data member, i.e., ‘status’ that will be used to show whether account is active or inactive.

If the balance of a savings account falls below RM 25, it becomes inactive and the account holder will not be able to perform withdraw operation anymore until the balance is raised above RM 25. If balance becomes greater than or equal to RM 25, the account will become active again.

The most common member functions of the SavingAccount class are given below.

depositAmount

A function which first checks whether the account is active/inactive before making a deposit. If inactive and the deposit brings the balance above RM 25, the account will become active again. The deposit will then be made by calling the base class version of the function.

withdrawAmount

A function which first checks whether the account is active/inactive before making a withdrawal. If active, the withdrawal will be made by calling the base class version of the function.

monthlyProcessing

This function first checks the no. of withdrawals before calling the base class version of this function. If the number of withdrawals are more than 4, a service charge of RM 1 for each withdrawal greater than or equal to RM 4 is added to the base class variable that holds the monthly service charges. Note: check the account balance after applying the service charge. If the balance become lower than RM 25, the account becomes inactive again.

Next step is to design a CheckingAccount class. It is also derived from the generic account class and should at least have the following member functions.

withdrawAmount

This function first determines whether a withdrawal request will cause the balance to go below RM 0. If it falls below RM 0, a service charge of RM 15 will be deducted from the account, and the withdrawal will not be made. If there is not enough amount to deduct the service charges, the balance will become negative accordingly.

monthlyProcessing

This function applies a monthly fee of RM 5 plus RM 0.10 per withdrawal to the base class variable that holds the monthly service charges.

Input Validations: Apply input validations wherever appropriate such as input data format for account number and title, and other validation checks applied in a practical banking system. Assume the account number is a 6-digit integer value (324561).

Implement the above functionality using abstraction methodology. This project requires to simulate one Saving and one Checking account, however, simulating multiple accounts (may be up to 5) is encouraged. If you simulate multiple accounts, highlight it in your report and the presentation file. You may need to add more member variables and functions than those listed above. Your application should at least provide the following functionality (a sample run):

Bank Account System

  1. Saving Account Number
  2. Saving Account Title
  3. Checking Account Number
  4. Checking Account Title
  5. Deposit in a Saving Account
  6. Deposit in a Checking Account
  7. Withdraw from Saving Account
  8. Withdraw from Checking Account
  9. Update and Display Account Statistics
  10. Exit

Upon selecting the desired option in the above menu, your application should perform the required functionality.

Solutions

Expert Solution

Code:-

///BankAccount.h///


#pragma once
#include<string>
using namespace std;
class BankAccount
{
protected:
   double balance;
   double rate = .05;
   int noOfDeposit;
   int noOfWithdrawal;
   int serviceCharge;
public:
   BankAccount()
   {
       balance=0;
       rate = .05;
       noOfDeposit=0;
       noOfWithdrawal=0;
       serviceCharge=0;
   }
   BankAccount(double b)
   {
       balance = b;
       rate = .05;
       noOfDeposit = 0;
       noOfWithdrawal = 0;
       serviceCharge = 0;
   }
   void setServiceCharge(double d)
   {
       serviceCharge = d;
   }
   double getBalance()
   {
       return balance;
   }
   virtual void depositAmount(double amt)
   {
       balance += amt;
       noOfDeposit++;
   }
   virtual void withdrawAmount(double amt)
   {
       if ((balance - amt) >= 0)
       {
           balance -= amt;
           noOfWithdrawal++;
       }    
   }
   virtual void calculateInterest()
   {
       balance += (balance*rate / 12);
   }
   virtual void monthlyProcessing()
   {
       calculateInterest();
       balance -= serviceCharge;
       noOfDeposit = 0;
       noOfWithdrawal = 0;
   }
   void getMonthlyStatistics()
   {
       cout << "Account balance is $" << balance;
       cout << "\nNumber of deposit per month is " << noOfDeposit;
       cout << "\nNumber of withdrawal per month is " << noOfWithdrawal;
   }
};


///CheckingAccount.h///
#pragma once
#include"BankAccount.h"
class SavingsBankAccount:public BankAccount
{
private:
   bool active;
public:
   SavingsBankAccount():BankAccount()
   {
       active = true;
   }
   SavingsBankAccount(double d) :BankAccount(d)
   {
       active = true;
   }
   virtual void depositAmount(double amt)
   {
       balance += amt;
       if (balance >= 25)
       {
           active = true;
       }
       noOfDeposit++;
   }
   virtual void withdrawAmount(double amt)
   {
       if ((balance - amt) >= 0 && active==true)
       {
           balance -= amt;
       }
       monthlyProcessing(amt);
       if (balance < 25)
       {
           active = false;
       }
       noOfWithdrawal++;

   }
   virtual void monthlyProcessing(double amt)
   {
       if (noOfWithdrawal > 4)
       {
           if (amt >= 4)
           {
               balance -= serviceCharge;
           }
       }
   }

};


///SavingsAccount.h///
#pragma once
#include"BankAccount.h"
class CheckingBankAccount :public BankAccount
{
private:
public:
   CheckingBankAccount() :BankAccount() {}
   CheckingBankAccount(double d) :BankAccount(d) {}
   virtual void depositAmount(double amt)
   {
       balance += amt;
       noOfDeposit++;
   }
   virtual void withdrawAmount(double amt)
   {
       balance -= amt;
       noOfWithdrawal++;
       if (balance < 0)
       {
           balance -= 15;
       }
       monthlyProcessing(amt);
   }
   virtual void monthlyProcessing(double amt)
   {
       if (amt >= 4)
       {
           balance -= serviceCharge;
       }
   }
};

Output:-

Please UPVOTE thank you...!!!


Related Solutions

using C++ Please create the class named BankAccount with the following properties below: // The BankAccount...
using C++ Please create the class named BankAccount with the following properties below: // The BankAccount class sets up a clients account (using name & id), and - keeps track of a user's available balance. - how many transactions (deposits and/or withdrawals) are made. public class BankAccount { private int id; private String name private double balance; private int numTransactions; // ** Please define method definitions for Accessors and Mutators functions below for the class private member variables string getName();...
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...
Create a class Team to hold data about a college sports team. The Team class holds...
Create a class Team to hold data about a college sports team. The Team class holds data fields for college name (such as Hampton College), sport (such as Soccer), and team name (such as Tigers). Include a constructor that takes parameters for each field, and get methods that return the values of the fields. Also include a public final static String named MOTTO and initialize it to Sportsmanship! Save the class in Team.java. Create a UML class diagram as well....
Create a class Team to hold data about a college sports team. The Team class holds...
Create a class Team to hold data about a college sports team. The Team class holds data fields for college name (such as Hampton College), sport (such as Soccer), and team name (such as Tigers). Include a constructor that takes parameters for each field, and get methods that return the values of the fields. Also include a public final static String named MOTTO and initialize it to Sportsmanship! Save the class in Team.java. Write an application named TestTeam with the...
java Objective: Create a class. Create objects. Use methods of a class. Create a class BankAccount...
java Objective: Create a class. Create objects. Use methods of a class. Create a class BankAccount to represent a bank account according to the following requirements: A bank account has three attributes: accountnumber, balance and customer name. Add a constructor without parameters. In the initialization of the attributes, set the number and the balance to zero and the customer name to an empty string. Add a constructor with three parameters to initialize all the attributes by specific values. Add a...
Using Java: Create a class that will hold the information about a clock, called Clock. You...
Using Java: Create a class that will hold the information about a clock, called Clock. You need to keep minutes, hours and seconds in military time (24-hour) format. Include member functions that will setTime ( this will set the hours, minutes and seconds of the clock), getHours (return the hours), getMinutes (return the minutes) and getSeconds (return the seconds). Another method printTime which will print the time out like this 03:13:09 (hours:minutes:seconds). Overloaded constructors that will take in hours, minutes...
In c++, define a class with the name BankAccount and the following members: Data Members: accountBalance:...
In c++, 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 Functions void withdraw(double amount): function which withdraws an amount from accountBalance void deposit(double...
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...
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...
Create a class named BankAccount, containing: a constructor accepting a String corresponding to the name of...
Create a class named BankAccount, containing: a constructor accepting a String corresponding to the name of the account holder. a method, getBalance, that returns a double corresponding to the account balance. a method withdraw that accepts a double, and deducts the amount from the account balance. Write a class definition for a subclass, CheckingAccount, that contains: a boolean instance variable, overdraft. (Having overdraft for a checking account allows one to write checks larger than the current balance). a constructor that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT