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

Please comment code with the following guidelines: Each class source code and he

ID: 3744130 • Letter: P

Question

Please comment code with the following guidelines:

Each class source code and header file should be preceded by the following documentation header:

///////////////////////////////////////////////////////////////////////

//

// Class: className                                          

//                                                                   

// Description:

//    Description of the class and its purpose        

//

//    List of data members

//

//    List of member functions                                       

//

///////////////////////////////////////////////////////////////////////

Each member or non-member function should be preceded by the following documentation header:

///////////////////////////////////////////////////////////////////////

//

// Function: functionName                                          

//                                                                   

// Description:

//    Description of the function

//

// Parameters:

//    firstParam : first parameter's description         

//    secondParam : second parameter's description               

//                                                       

// Returns:

//    returnVal : description of what is returned to caller                 

//                                            

///////////////////////////////////////////////////////////////////////

#include <iostream>

using namespace std;

class BankAccount {
public:
   const int uid;
   BankAccount() : uid(accountID++) {
       accountBalance = 0.0;
   }

   BankAccount(double balance1) : uid(accountID++) {
       accountBalance = balance1;
   }

   int get_actNumber() {
       return uid;
   }
   void deposit(double amount) {
       accountBalance = accountBalance + amount;
   }
   void withdraw(double amount) {
       accountBalance = accountBalance - amount;
   }
   double get_balance() {
       return accountBalance;
   }
   int count() {
       return uid;
   }

protected:
   double accountBalance;
   static int accountID;
};

int BankAccount::accountID = 100;

class SavingsAccount : public BankAccount {
public:
   SavingsAccount(double balance)
       : BankAccount(balance) {
       rate = .06;
   }

   void set_interestRate(double rate) {
       rate = rate;
   }

   double get_interestRate() {
       return rate;
   }

   void postInterest() {
       accountBalance += (accountBalance * rate);
   }

   void withDraw(double amount) {
       if (accountBalance >= amount) {
           accountBalance = accountBalance - amount;
       }
       else {
           cout << "Insufficient funds. Withdrawl transaction rejected, balance remains the same" << endl;
       }
   }

   void displayAccountInfo() {
       cout << "Interest Saving ACCT#:" << get_actNumber() << " Balance: $" << get_balance() << endl;
   }

   void calculateMonthlyInterest() {
       accountBalance = accountBalance + (rate * accountBalance);
   }
protected:
   double rate;

};

class CheckingAccount : public BankAccount {
private:
   int fee;
   float minBalance;
   float rate;

public:
   CheckingAccount(double balance)
       : BankAccount(balance)
   {
       //_number = get_actNumber();
       fee = 50;
       minBalance = 500;
       rate = 0.04;
   }

   void set_interestRate(double rate) {
       rate = rate;
   }
   double get_interestRate() {
       return rate;
   }
   void set_minBalance(double minBal) {
       minBalance = minBal;
   }
   double get_minBalance() {
       return minBalance;
   }
   bool checkMin() {
       if (accountBalance >= minBalance)
       {
           return true;
       }
       else
           return false;
   }
   void set_fee(double fee1) {
       fee = fee1;
   }
   double get_fee() {
       return fee;
   }
   void postInterest() {
       accountBalance += (accountBalance * rate);
   }
   void withDraw(double amount) {
       if (accountBalance < amount) {
           cout << "insufficient funds. Withdrawl rejected, does not affect balance." << endl;
       }
       else {
           if (accountBalance - amount >= minBalance) {
               accountBalance = accountBalance - amount;
           }
           else
           {
               accountBalance -= (amount + fee);

           }

       }
   }
   void displayAccountInfo() {
       cout << "Interest Checking ACCT#:" << get_actNumber() << " Balance: $" << get_balance() << endl;
   }
   void calculateMonthlyInterest() {
       accountBalance = accountBalance + (rate * accountBalance);
   }
};

int main() {
   CheckingAccount jackAccount(1000);
   CheckingAccount lisaAccount(450);
   SavingsAccount samirAccount(9300);
   SavingsAccount ritaAccount(32);
   jackAccount.deposit(1000);
   lisaAccount.deposit(2300);
   samirAccount.deposit(800);
   ritaAccount.deposit(500);
   jackAccount.calculateMonthlyInterest();
   lisaAccount.calculateMonthlyInterest();
   samirAccount.calculateMonthlyInterest();
   ritaAccount.calculateMonthlyInterest();
   cout << "***********************************" << endl;
   jackAccount.displayAccountInfo();
   lisaAccount.displayAccountInfo();
   samirAccount.displayAccountInfo();
   ritaAccount.displayAccountInfo();
   cout << "***********************************" << endl << endl;
   jackAccount.withDraw(250);
   lisaAccount.withDraw(350);
   samirAccount.withdraw(120);
   ritaAccount.withdraw(290);
   cout << "********After withdrawals ***************" << endl;
   jackAccount.displayAccountInfo();
   lisaAccount.displayAccountInfo();
   samirAccount.displayAccountInfo();
   ritaAccount.displayAccountInfo();
   cout << "***********************************" << endl << endl;
   system("pause");
   return 0;
}

Explanation / Answer

#include <iostream>

using namespace std;

//class BankAccout

/// Base class

class BankAccount {

public:

//data member

const int uid;

//methods...or operations

//CONSTRUCTOR

BankAccount() : uid(accountID++) {

//incrementing accountID

//setting accountBalance variable value... to 0

accountBalance = 0.0;

}

//parameterized constructor..

BankAccount(double balance1) : uid(accountID++) {

//parameter balance1

//parameter type : double

//incrementing accountID

//setting accountBalance variable value... to balance1

accountBalance = balance1;

}

//method name : get_actNumber

//return type : int

//returns const int uid

int get_actNumber() {

return uid;//returning const int uid variable

}

//method name : deposit

//return type : void

//increments accountBalance by given amount as parameter

void deposit(double amount) {

//parameter: amount

//parameter type: double

accountBalance = accountBalance + amount;//incrementing accountBalance

}

//method name : withdraw

//return type : void

//decrements accountBalance by given amount as parameter

void withdraw(double amount) {

//parameter: amount

//parameter type: double

accountBalance = accountBalance - amount;//decrementing accountBalance

}

//method name : get_balance

//return type : double

//returns the accountBalance

double get_balance() {

return accountBalance;//returning accountBalance

}

//method name : count

//return type : int

//returns const int uid

int count() {

return uid;//

//returning const int uid

}

//protected data memeber //declarations

protected:

double accountBalance;

static int accountID;

};

///

//Global declaration

int BankAccount::accountID = 100;

//class SavingsAccount

//sub class

//inherits properties of BankAccount

class SavingsAccount : public BankAccount

{

public:

//parameterized constructor...

SavingsAccount(double balance)

: BankAccount(balance) {

//parameter balance1

//parameter type : double

//and passing parameter to constructor BankAccount also...to set accountBalance variable value... to balance1

rate = .06;//setting variable rate to 06

}

//method name : set_interestRate

//return type : void

//parameter : rate

//parameter type: double

//this method sets the variable rate to given..input..rate parameters value..

void set_interestRate(double rate) {

rate = rate;//setting rate...

}

//method name : get_interestRate

//return type : double

//returns rate value..

double get_interestRate() {

return rate;//returning rate value

}

//method name : postInterest

//return type : void

//increments accountBalance variable by accountBalance * rate

void postInterest() {

accountBalance += (accountBalance * rate);//incrementing accountBalance variable by accountBalance * rate

}

//method name : withdraw

//return type : void

//parameter : amount

//parameter type: double

void withDraw(double amount) {

//if accountBalance is greater than amount

if (accountBalance >= amount) {

accountBalance = accountBalance - amount;//then decrement accountBalance by amount times

}

else {

//otherwise printing error....... message

cout << "Insufficient funds. Withdrawl transaction rejected, balance remains the same" << endl;

}

}

//method name : displayAccountInfo

//return type : void

//method to display account info..

void displayAccountInfo() {

//displaying account info

cout << "Interest Saving ACCT#:" << get_actNumber() << " Balance: $" << get_balance() << endl;

}

//method name : calculateMonthlyInterest

//return type : void

//method to update accountBalance by accountBalance + (rate * accountBalance)

void calculateMonthlyInterest() {

accountBalance = accountBalance + (rate * accountBalance);//updating account balance

}

//data member...

protected:

double rate;//data variable rate...

};

//class CheckingAccount

//sub class

//inherits properties of BankAccount

class CheckingAccount : public BankAccount {

//private datamembers declarations..

private:

int fee;

float minBalance;

float rate;

public:

//parameterized constructor...

CheckingAccount(double balance) : BankAccount(balance)

{

//parameter balance1

//parameter type : double

//and passing parameter to constructor BankAccount also...to set accountBalance variable value... to balance1

//_number = get_actNumber();

//setting variable values

fee = 50;

minBalance = 500;

rate = 0.04;

}

//method name : set_interestRate

//return type : void

//parameter : rate

//parameter type: double

//this method sets the variable rate to given..input..rate parameters value..

void set_interestRate(double rate) {

rate = rate;//setting rate

}

//method name : get_interestRate

//return type : double

//returns rate value..

double get_interestRate() {

return rate;//returning rate value

}

//method name : set_minBalance

//return type : void

//parameter : minBal

//parameter type: double

//method to set minBalance variable...

void set_minBalance(double minBal) {

//setting minbalance

minBalance = minBal;

}

//method name : get_minBalance

//return type : double

//returns minBalance

double get_minBalance() {

//returning minBalance variable value

return minBalance;

}

//method name : checkMin

//return type : bool

bool checkMin() {

//if accountBalance greater than minBalance

if (accountBalance >= minBalance)

{

return true;//then returning true

}

else//or else returning false

return false;

}

//method name : set_fee

//return type : void

//parameter : feel

//parameter type: double

//this method sets variable fee

void set_fee(double fee1) {

fee = fee1;//setting variable fee

}

//method name : get_fee

//return type : double

//returns value of variable fee

double get_fee() {

return fee;//returning fee

}

//method name : postInterest

//return type : void

//increments accountBalance variable by accountBalance * rate

void postInterest() {

accountBalance += (accountBalance * rate);//incrementing accountBalance variable by accountBalance * rate

}

//method name : withdraw

//return type : void

//parameter : amount

//parameter type: double

void withDraw(double amount) {

//if accountBalance is greater than amount

if (accountBalance >= amount) {

accountBalance = accountBalance - amount;//then decrement accountBalance by amount times

}

else { if (accountBalance - amount >= minBalance) {

accountBalance = accountBalance - amount;

}

else

{

accountBalance -= (amount + fee);

}

}

}

//method name : displayAccountInfo

//return type : void

//method to display account info..

void displayAccountInfo() {

//displaying account info

cout << "Interest Saving ACCT#:" << get_actNumber() << " Balance: $" << get_balance() << endl;

}

//method name : calculateMonthlyInterest

//return type : void

//method to update accountBalance by accountBalance + (rate * accountBalance)

void calculateMonthlyInterest() {

accountBalance = accountBalance + (rate * accountBalance);//updating account balance

}

};

//tester function

int main() {

//declaring CheckingAccount variables

CheckingAccount jackAccount(1000);

CheckingAccount lisaAccount(450);

//declaring SavingsAccount variables

SavingsAccount samirAccount(9300);

SavingsAccount ritaAccount(32);

//calling deposit from CheckingAccount variables

jackAccount.deposit(1000);

lisaAccount.deposit(2300);

//calling deposit from SavingsAccount variables

samirAccount.deposit(800);

ritaAccount.deposit(500);

//calling calculateMonthlyInterest from CheckingAccount variables

jackAccount.calculateMonthlyInterest();

lisaAccount.calculateMonthlyInterest();

//calling calculateMonthlyInterest from SavingsAccount variables

samirAccount.calculateMonthlyInterest();

ritaAccount.calculateMonthlyInterest();

//displaying displayAccountInfo() from all variables

cout << "***********************************" << endl;

jackAccount.displayAccountInfo();

lisaAccount.displayAccountInfo();

samirAccount.displayAccountInfo();

ritaAccount.displayAccountInfo();

//calling withdraw from all variables

cout << "***********************************" << endl << endl;

jackAccount.withDraw(250);

lisaAccount.withDraw(350);

samirAccount.withdraw(120);

ritaAccount.withdraw(290);

//displaying displayAccountInfo() from all variables

cout << "********After withdrawals ***************" << endl;

jackAccount.displayAccountInfo();

lisaAccount.displayAccountInfo();

samirAccount.displayAccountInfo();

ritaAccount.displayAccountInfo();

cout << "***********************************" << endl << endl;

system("pause");

return 0;

}

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