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

Please hlep as I\'ve tried this C++ program and keep coming up with the wrong sy

ID: 3661631 • Letter: P

Question

Please hlep as I've tried this C++ program and keep coming up with the wrong syntax somewhere. I need help defining 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 process up to 10 customers and write a program to illustrate how to use your class.

Explanation / Answer

#include <iostream>

   using namespace std;

//BankAccount - Base Abstract Class with virtual withdraw function

   class BankAccount

   {

   protected:

        double balance;

        double amount;

   public:

        BankAccount();

        BankAccount(double bal);

        double getBalance();

        double deposit();

        virtual int withdraw(double amt) = 0;

   };

  

   //CheckingAccount - Derived Class

   class CheckingAccount : public BankAccount

   {

   private:

        int withdrawals;

  

   public:

        CheckingAccount();

        CheckingAccount(double bal, int wd);

        double withdraw();

        virtual int withdraw(double amt);

   };

  

   //SavingsAccount - Derived Class

   class SavingsAccount : public BankAccount

   {

   private:

        double fee;

  

   public:

        SavingsAccount();

    SavingsAccount(double bal, int wd, double fee);

        virtual int withdraw(double amt);

   };
  

   //function used to perform transactions

void transfer(BankAccount& fromAccount, BankAccount& toAccount, double amount);

  

   void main()

   {

   //declare objects using overloaded constructors

        CheckingAccount checking(100.00);

        SavingsAccount savings(200.00);

  

        //Set the decimal point to 2 positions

        cout.setf(ios::fixed);

        cout.setf(ios::showpoint);

        cout.precision(2);

  

        cout << "P04 Name ";

  

        cout << "Initial Balances" << endl;

        cout << " Checking: " << checking.getBalance();

        cout << " Savings: " << savings.getBalance() << endl << endl;

  

   //**

        cout << "Transfer from Checking to Savings, Amount: 25.00 (3 transactions) "

             << "First 2 withdrawals from Checking are free; others 1.50 fee ";

  

        transfer(checking, savings, 25.00);

        transfer(checking, savings, 25.00);

        transfer(checking, savings, 25.00);

  

        cout << " Checking: " << checking.getBalance();

        cout << " Savings: " << savings.getBalance() << endl << endl;

  

   //**

        cout << "Transfer from Savings to Checking, Amount: 100.00 "

             << "10% fee is $10.00, total deduction 110.00 ";

  

        transfer(savings, checking, 100.00);

  

        cout << " Checking: " << checking.getBalance();

        cout << " Savings: " << savings.getBalance() << endl << endl;

  

   //**

        cout << "Transfer from Savings to Checking, Amount: 166.00 ";

  

        transfer(savings, checking, 166.00);

  

        cout << " Checking: " << checking.getBalance();

        cout << " Savings: " << savings.getBalance() << endl << endl;

  

   //**

        cout << "Transfer from Checking to Savings, Amount: 123.00 + 1.50 fee. ";

  
        transfer(checking, savings, 123.00);

  

        cout << " Checking: " << checking.getBalance();

        cout << " Savings: " << savings.getBalance() << endl << endl;

  

        return;

   }

   //end of main

  

   //BankAccount is abstract, but can still be used as a pointer to derived objects

   void transfer(BankAccount& fromAccount, BankAccount& toAccount, double amount)

   {

        int insufficientFunds;

  

        insufficientFunds = fromAccount.withdraw(amount);

        if (insufficientFunds == 1)

            cout << "*** Transfer failed - insufficient funds *** ";

        else

            toAccount.deposit(amount);

  

        return;

   }

   //BankAccount Definition

   BankAccount::BankAccount()

   {

   }

   BankAccount::BankAccount(double bal)

   {

        balance = bal;

   }

   double BankAccount::getBalance()

   {

        return balance;

   }

   double BankAccount::deposit()

   {

        if (amount >= 0)

        {

            balance = balance + amount;

        }

        return balance;

   }

   int BankAccount::withdraw(double amt)

   {

        if (amount > 0)

        {

            balance = balance - amount;

        }
        return balance;
   }

   //CheckingAccount Definition
   CheckingAccount::CheckingAccount()
   {

   }

   CheckingAccount::CheckingAccount(double bal, int wd)

   {

        withdrawals = wd;

   }

   double CheckingAccount::withdraw()

   {
   

   }

   int CheckingAccount::withdraw(double amt)

   {

        if ((BankAccount::getBalance() - amount) >= 0)

        {
       BankAccount::withdraw(amount);

        }

   }

  

   //SavingsAccount Definition

   SavingsAccount::SavingsAccount()

   {

   }

   SavingsAccount::SavingsAccount(double bal, int wd, double fee)

   {

        fee = fee;

   }

   int CheckingAccount::withdraw(double amt)

   {

        if ((BankAccount::getBalance() - amount) >= 0)

        {

            BankAccount::withdraw(amount);

        }

   }

  

   //end of program