Ok. I've redone my project from what I had before, and I still can't get the program to add interest and charges to the balance. Help would be greatly appreciated.
===========================================================

This is what I have so far in my .cpp file and my .h file:


Contents of Bbankaccount.cpp
=====================

#include <iostream>
#include <conio>
#include <iomanip>
#include <fstream>
#include <stdlib>
#include <dir>

#include "baccount.h"
using namespace std;

//These are all the functions used
void Deposit(double bal);
void Withdrawals(double bal);
void Balance(double bal);
void Interest(double bal);
void Menu();
void Charges(double bal);
void Exit();

//These are the variables used
double Dnum;
double bal;
double Wnum;
char select;

int main(){

Menu();

getch();
return 0;
}


//The deposit function handles deposits coming into the program
void Deposit(){
clrscr();

cout <<"\n\tEnter an amount: $";
cin >> Dnum;
Interest(bal);
Charges(bal);

ifstream balin("Bank.txt");
balin >> bal;
balin.close();

bal = bal + Dnum;

if(Dnum != 0)
{
ofstream Depo("Bank.txt");
Depo << bal;
Depo.close();

cout <<"\n\tAmount deposited: $" << Dnum << endl;
cout <<"\n\n\tYour balance is now: $" << bal << endl;
}

else
{
cout <<"\n\tIncorrect amount, try again." << endl;
getch();
Menu();
}

cout <<"\n\n\tPress any key to contine..." << endl;
getch();
Menu();
}


void Withdrawal(){
clrscr();

cout <<"\n\tEnter an amount: ";
cin >>Wnum;
Interest(bal);
Charges(bal);

if(Wnum != 0)
{
ifstream Without("Bank.txt");
Without >> bal;
Without.close();

bal = bal - Wnum;

if(bal < 0){
cout <<"Your account can not be negative, please enter another amount." << endl;
getch();
Withdrawal();
}

ofstream Within("Bank.txt");
Within << bal;
Within.close();
}

cout <<"\n\n\tAmount withdrawn: $" << Wnum;
cout <<"\n\n\tYour balance is now: $" << bal;

cout <<"\n\n\tPress any key to continue..." << endl;
getch();
Menu();
}

void Interest(double){

double bal;
double monthlyintrate;
double monthlyint;
double annintrate;

  if(bal >= 25)
  monthlyintrate = (annintrate/12);
  monthlyint = bal * monthlyintrate;
  bal = bal + monthlyint;
}

void Charges(double){

double withdraw;
double bal;

  if(withdraw >= 4)
  {
    withdraw++;
    bal = bal - 1;
  }
  else
  {
    withdraw++;
    bal = bal - (5 + 0.10);
  }
}


void Balance(){
clrscr();
double bal;


ifstream Balout("Bank.txt");
Balout >> bal;
Balout.close();

if(bal >= 25)
{
bal = bal;
}
ofstream Balin("Bank.txt");
Balin << bal;
Balin.close();

cout <<"\n\tYour current balance is: " << bal;
cout <<"\n\nPress any key to continue..." << endl;
getch();
Menu();
}


void Exit(){
cout <<"\n\n\tEnd of program. Press any key to exit..." << endl;
}


void Menu(){
clrscr();

cout <<"\t\t\tBanking Program" << endl;
cout <<"\t\t\t================" << endl;

cout <<"\n\n\t1) Make a Deposit" << endl;
cout <<"\n\t2) Make a Withdrawal" << endl;
cout <<"\n\t3) Check your Balance" << endl;
cout <<"\n\t4) Quit" << endl;

cout <<"\n\n\tEnter your selection: ";
cin >> select;

if(select == '1')
{
Deposit();
}
else if(select == '2')
{
Withdrawal();
}
else if(select == '3')
{
Balance();
}
else if(select == '4')
{
Exit();
}
}

Contents of baccount.h
================

#include <string>
using namespace std;

class Account {
protected:
  double bal;
  double dep;
  double with;
  double interest;
  double charges;
  double balance;
  double deposit;
  double withdraw;
  double calcInt;
  double monthlyProc;
  double monthlyint;
  double monthlyintrate;
  double annintrate;
public:
  Balance() { getBalance(); return balance; }
  NumDeposits()
  {
    getNumDep();
    deposit++;

    return deposit;
  }
  NumWithdrawals()
  {
    getNumWith();
    withdraw++;

    return withdraw;
  }
  Interest()
  {
    getInt();
    if(bal >= 25)
    monthlyintrate = (annintrate/12);
    monthlyint = bal * monthlyintrate;
    bal = bal + monthlyint;

    return calcInt;
  }
  Charges()
  {
    getCharges();
    if(withdraw >= 4)
    {
      withdraw++;
      bal = bal - 1;
    }
    else
    {
      withdraw++;
      bal = bal - (5 + 0.10);
    }

    return monthlyProc;
  }

virtual void setBalance(double bal) { balance = bal; }
virtual void setNumDep(double dep) { deposit = dep; }
virtual void setNumWith(double with) { withdraw = with; }
virtual void setInt(double interest) { calcInt = interest; }
virtual void setCharges(double charges) { monthlyProc = charges; }

virtual double getBalance() { return balance; }
virtual double getNumDep() { return deposit; }
virtual double getNumWith() { return withdraw; }
virtual double getInt() { return calcInt; }
virtual double getCharges() { return monthlyProc; }
};


class Savings:public Account
{
private:
  bool status;
  double bal;
  double monthlyintrate;
  double annintrate;
  double monthlyint;

public:
  Savings()
  {
    getBalance();
    if(balance >= 25)
    status = true;
    else
    status = false;
  }
  Balance() { getBalance(); return balance; }
  NumDeposits() { getNumDep(); return deposit; }
  NumWithdrawals() { getNumWith(); return withdraw; }
  Interest()
  {
    getInt();
    if(bal >= 25)
    monthlyintrate = (annintrate/12);
    monthlyint = bal * monthlyintrate;
    bal = bal + monthlyint;

    return calcInt;
  }
  Charges()
  {
    getCharges();
    if(withdraw >= 4)
    withdraw++;
    bal = bal - 1;

    return monthlyProc;
  }

void setBalance(double bal) { balance = bal; }
void setNumDep(double dep) { deposit = dep; }
void setNumWith(double with) { withdraw = with; }
void setInt(double interest) { calcInt = interest; }
void setCharges(double charges) {monthlyProc = charges; }

double getBalance() { return balance; }
double getNumDep() { return deposit; }
double getNumWith() { return withdraw; }
double getInt() { return calcInt; }
double getCharges() { return monthlyProc; }
};


class Checking : public Account
{
private:
  bool status;
  double bal;
  double monthlyintrate;
  double annintrate;
  double monthlyint;

public:
  Checking()
  {
    getBalance();
    if(balance >= 25)
    status = true;
    else
    status = false;
  }
  Balance() { getBalance(); return balance; }
  NumDeposits() { getNumDep(); return deposit; }
  NumWithdrawals() { getNumWith(); return withdraw; }
  Interest()
  {
    getInt();
    if(bal >= 25)
    monthlyintrate = (annintrate/12);
    monthlyint = bal * monthlyintrate;
    bal = bal + monthlyint;

    return calcInt;
  }
  Charges()
  {
    getCharges();
    if(withdraw >= 4)
    withdraw++;
    balance = balance - (5 + 0.10);
    monthlyProc = balance;

    return monthlyProc;
  }

void setBalance(double bal) { balance = bal; }
void setNumDep(double dep) { deposit = dep; }
void setNumWith(double with) { withdraw = with; }
void setInt(double interest) { calcInt = interest; }
void setCharges(double charges) {monthlyProc = charges; }

double getBalance() { return balance; }
double getNumDep() { return deposit; }
double getNumWith() { return withdraw; }
double getInt() { return calcInt; }
double getCharges() { return monthlyProc; }
};

================================================================
Basically I have to add a virtual function called calcInt into the Account class that updates the balance by calculating the monthly interest earned by the account, and add the interest to the balance with this formula:

Monthly Interest Rate = (Annual Interest Rate / 12)
Monthly Interest = Balance * Monthly Interest Rate
Balance = Balance + Monthly Interest

Also, I have to have a virtual function in the Account class called monthlyProc that subtracts the monthly service charges from the balance, calls the calcInt function, and sets the variables that hold the number of withdraws, number of deposits, and monthly service charges to zero.

Then I have to add the member function monthlyProc to the Savings account class, that does this:

Before the base class function is called, this function checks the number of withdrawals. If the number of withdrawals for the month is more than four, a service charge of $1 for each withdrawal above four is added to the base class variable that holds the monthly service charges(Don't forget to check the account balance after the service charges is taken. If the balance falls below $25, the account becomes inactive.)

I also have to add the member function monthlyProc to the Checking account class, that does this:

Before the base class function is called, this function adds the monthly fee of $5 plus $0.10 per withdrawal to the base class variable that holds the monthly service charges.

You've alread used virtual functions in your code (lines 62-72) so presumably you know what they are in addition to how, why and when to use them, etc.

In addition you already have code (lines 101-103) to do the calculations you want to do in calcInt().

Therefore I don't understand why you would have touble creating the calcInt() function you want to create and use it and the instructions you're given to complete the project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.