Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a menu that allows you to select the account type and then gives you opti

ID: 3866744 • Letter: C

Question

Create a menu that allows you to select the account type and then gives you option:

1) deposit
2) withdraw
3) check balance
4) monthly processing
5) exit

Use BankAccount pointers and polymorphism.

#include <iostream>
#include <stdbool.h>
#include "BankAccount.h"

using namespace std;

class SavingAccount : public BankAccount
{
   private:
    bool status;
  
   public:
    SavingAccount(double balace, double rate): BankAccount(balace,rate)
    {

    }

    bool checkStatus()
    {
        if (BankAccount::balance < 25.0)
        return false;

        else
        return true;
    }

    void withdraw(double amount)
    {
        if (checkStatus())
        {
            BankAccount::withdraw(amount);
        }
    }

    void deposit(double amount)
    {
        if (checkStatus() == false)
        {
            if (BankAccount::balance + amount > 25)
            status = true;
        }

        BankAccount::deposit(amount);
    }

    void monthlyProc()
    {
        if (BankAccount::noOfWithdrawl > 4)
        {
            BankAccount::monthlyServiceCharge += 1;
            BankAccount::balance -= 1;

            if (BankAccount::balance < 25)
            status = false;
        }
    }
};

class CheckingAccount :public BankAccount
{
    public:
    CheckingAccount(double balace, double rate) : BankAccount(balace, rate)
    {

    }

    void withdraw(double amount)
    {
        if (balance - amount < 0)
        {
           monthlyServiceCharge += 15;
           balance -= 15;
        }

        else
        BankAccount::withdraw(amount);
    }

    void monthlyProc()
    {
        monthlyServiceCharge += 5;
        monthlyServiceCharge += 0.10*noOfWithdrawl;
    }
};

int main()
{
    BankAccount *saving = new SavingAccount(100,15);
    cout << "please enter amount to deposit in saving account: ";

    double depositAmount, withdrawAmount;
    cin >> depositAmount;
    saving->deposit(depositAmount);

    double monthStartBalance = depositAmount;
    cout << "please enter amount to withdraw from saving account: ";
    cin >> withdrawAmount;
    saving->withdraw(withdrawAmount);

    cout << "Month start balance: " << monthStartBalance << endl;
    cout << "Total No of depost: " << saving->getNoOfDeposit() << endl;
    cout << "Total no of withdrawl: " << saving->getNoOfWithdrawl() << endl;
    cout << "Monthly service charge: " << saving->getMonthleServiceCharge() << endl;
    cout << "Month Ending balance: " << saving->getbalance() << endl;

    //Checkingaccount
    BankAccount *checking = new CheckingAccount(500, 10);
    cout << "please enter amount to deposit in checking account: ";
    cin >> depositAmount;
    checking->deposit(depositAmount);

    monthStartBalance = depositAmount;
    cout << "please enter amount to withdraw from checking account: ";
    cin >> withdrawAmount;
    checking->withdraw(withdrawAmount);
    cout << "Month start balance: " << monthStartBalance << endl;
    cout << "Total No of depost: " << checking->getNoOfDeposit() << endl;
    cout << "Total no of withdrawl: " << checking->getNoOfWithdrawl() << endl;
    cout << "Monthly service charge: " << checking->getMonthleServiceCharge() << endl;
    cout << "Month Ending balance: " << checking->getbalance() << endl;

    getchar();
    return 0;
}

//BankAccount.h

#pragma once
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H

class BankAccount
{
    protected:
        double balance;
        int noOfDeposit;
        int noOfWithdrawl;
        double AnnualInterestRate;
        double monthlyServiceCharge;
  
    public:
        BankAccount(double bal, double interestRate)
        {
            balance = bal;
            AnnualInterestRate = interestRate;
            noOfDeposit = 0;
            noOfWithdrawl = 0;
            monthlyServiceCharge = 0;
        }

    virtual void deposit(double amount)
    {
        balance += amount;
        noOfDeposit++;
    }

    virtual void withdraw(double amount)
    {
       balance -= amount;
       noOfWithdrawl++;
    }

    virtual void calcint()
    {
        double MonthlyInterestRate = (AnnualInterestRate / 12);
        double MonthlyInterest = balance * MonthlyInterestRate;
        balance = balance + MonthlyInterest;
    }

    virtual void monthlyProc()
    {
        balance -= monthlyServiceCharge;
        calcint();
        noOfDeposit = 0;
        noOfWithdrawl = 0;
        monthlyServiceCharge = 0;
    }

    double getbalance()
    {
       return balance;
    }

    int getNoOfDeposit()
    {
        return noOfDeposit;
    }

    int getNoOfWithdrawl()
    {
        return noOfWithdrawl;
    }

    double getMonthleServiceCharge()
    {
        return monthlyServiceCharge;
    }
};

#endif

Explanation / Answer

The menu for the program is as follows:

Bank.cpp

#include <iostream>
#include <stdbool.h>
#include "BankAccount.h"
using namespace std;
class SavingAccount : public BankAccount
{
private:
bool status;
  
public:
SavingAccount(double balace, double rate): BankAccount(balace,rate)
{
}
bool checkStatus()
{
if (BankAccount::balance < 25.0)
return false;
else
return true;
}
void withdraw(double amount)
{
if (checkStatus())
{
BankAccount::withdraw(amount);
}
}
void deposit(double amount)
{
if (checkStatus() == false)
{
if (BankAccount::balance + amount > 25)
status = true;
}
BankAccount::deposit(amount);
}
void monthlyProc()
{
if (BankAccount::noOfWithdrawl > 4)
{
BankAccount::monthlyServiceCharge += 1;
BankAccount::balance -= 1;
if (BankAccount::balance < 25)
status = false;
}
}
};
class CheckingAccount :public BankAccount
{
public:
CheckingAccount(double balace, double rate) : BankAccount(balace, rate)
{
}
void withdraw(double amount)
{
if (balance - amount < 0)
{
monthlyServiceCharge += 15;
balance -= 15;
}
else
BankAccount::withdraw(amount);
}
void monthlyProc()
{
monthlyServiceCharge += 5;
monthlyServiceCharge += 0.10*noOfWithdrawl;
}
};
int main()
{
do
{
system("cls");
cout<<" MAIN MENU";
cout<<" 01. DEPOSIT AMOUNT";
cout<<" 02. WITHDRAW AMOUNT";
cout<<" 03. BALANCE ENQUIRY";
cout<<" 04. MONTHLY PROCESSING";
cout<<" 05. EXIT";
cout<<" Select Your Option (1-5) ";
cin>>ch;
system("cls");
switch(ch)
{
case '1':
cout<<" Enter The amount to be deposited. : "; cin>>num;
deposit(10000);
break;
case '2':
cout<<" Enter The amount to be withdrawn. : "; cin>>num;
withdraw(1200);
break;
case '3':
cout<<" Enter The account No. : "; cin>>num;
checkStatus();
break;
case '4':
monthlyProc();
break;
case '5':
cout<<" Thanks for using bank managemnt system";
break;
default :cout<<"a";
}
cin.ignore();
cin.get();
}while(ch!='5');
return 0;
}

Please rate the answer if it helped........Thankyou

Hope it helps.....

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote