//header.h
#include <iostream>
using namespace std;
class Account
{
protected:
double beginBal;
double balance;
double dnum;
double wnum;
double charges;
double annintrate;
public:
Account();
Account(double,double);
virtual void deposit(double);
virtual void withdraw(double);
virtual void calcInt();
virtual void monthlyProc();
virtual void setBalance(double bal){ balance=bal;}
virtual void setDnum(double d){ dnum=d;}
virtual void setWnum(double w){ wnum=w;}
virtual void setCharges(double c){ charges=c;}
virtual void setAnnintrate(double a){ annintrate=a;}
double getBalance(){ return balance;}
double getDnum(){ return dnum;}
double getWnum(){ return wnum;}
double getCharges(){ return charges;}
double getAnnintrate(){ return annintrate;}
};
class Saving : public Account
{
private:
bool status ;
public:
Saving();
void deposit(double);
void withdraw(double);
void MonthlyProc();
void setStatus(bool);
bool getStatus();
};
class checking : public Account
{
public:
checking();
void withdraw(double);
void monthlyProc();
};
//Account.cpp
#include "header.h"
using namespace std;
Account::Account()
{
}
Account::Account(double bal=200,double air=0.12)
{
balance=bal;
annintrate=air;
beginBal=bal;
}
void Account::deposit(double dep)
{
balance=balance+dep;
dnum++;
}
void Account::withdraw(double with)
{
balance=balance-with;
wnum++;
}
void Account::calcInt()
{
double MIR,MI;
MIR= annintrate / 12;
MI = balance * MIR;
balance = balance + MI;
}
void Account::monthlyProc()
{
balance=balance-charges;
calcInt();
wnum=0;
dnum=0;
charges=0;
}
//saving.cpp
#include "header.h"
#include <iostream>
using namespace std;
Saving::Saving()
{
}
void Saving::deposit(double d)
{
if (balance+d > 25.0)
{
setStatus(true);
cout <<"\nthanks your deposit will make your account active."<<endl;
}
else
{
setStatus(false);
cout <<"\nSorry your depositing will not make the account active."<<endl;
}
Account::deposit(d);
}
void Saving::withdraw(double w)
{
if (balance >= 25)
{
setStatus(true);
}
else
{
setStatus(false);
}
}
void Saving::MonthlyProc()
{
if(wnum>4)
{
charges=1;
}
//checking::monthlyProc();
}
void Saving::setStatus(bool tf)
{
status=tf;
}
bool Saving::getStatus()
{
return status;
}
//checking.cpp
#include "header.h"
#include <iostream>
using namespace std;
checking::checking()
{
}
void checking::withdraw(double w)
{
double with=w;
if(balance-wnum<0)
{
charges=15;
balance=balance-charges;
if(balance-charges<0)
cout<<"you have to pay "<<charges-balance<<" to the bank.";
}
Account::withdraw(with);
}
void checking::monthlyProc()
{
charges=charges+(5+0.10);
Account::monthlyProc();
}
//main.cpp
#include <iostream>
using namespace std;
class Account
{
protected:
double beginBal;
double balance;
double dnum;
double wnum;
double charges;
double annintrate;
public:
Account(double bal=200,double air=0.12)
{
balance=bal;
annintrate=air;
beginBal=bal;
}
virtual deposit(double dep)
{
balance=balance+dep;
dnum++;
}
virtual withdraw(double with)
{
balance=balance-with;
wnum++;
}
virtual void calcInt();
virtual void monthlyProc();
virtual void setBalance(double bal){ balance=bal;}
virtual void setDnum(double d){ dnum=d;}
virtual void setWnum(double w){ wnum=w;}
virtual void setCharges(double c){ charges=c;}
virtual void setAnnintrate(double a){ annintrate=a;}
double getBalance(){ return balance;}
double getDnum(){ return dnum;}
double getWnum(){ return wnum;}
double getCharges(){ return charges;}
double getAnnintrate(){ return annintrate;}
};
class Saving : public Account
{
private:
bool status ;
public:
Saving();
void deposit(double);
void withdraw(double);
void MonthlyProc();
void setStatus(bool);
bool getStatus();
};
class checking : public Account
{
public:
checking();
void withdraw(double);
void monthlyProc();
};
in saving.cpp in function deposit
void Saving::deposit(double d)
{
if (balance+d > 25.0)
{
setStatus(true);
cout <<"\nthanks your deposit will make your account active."<<endl;
}
else
{
setStatus(false);
cout <<"\nSorry your depositing will not make the account active."<<endl;
}
Account::deposit(d);
}
cannot do (balance + d)
i think it cannot read balance but i dont knoe why because class saving is inharited to the base class
#include <iostream>
using namespace std;
class Account
{
protected:
double beginBal;
double balance;
double dnum;
double wnum;
double charges;
double annintrate;
public:
Account();
Account(double,double);
virtual void deposit(double);
virtual void withdraw(double);
virtual void calcInt();
virtual void monthlyProc();
virtual void setBalance(double bal){ balance=bal;}
virtual void setDnum(double d){ dnum=d;}
virtual void setWnum(double w){ wnum=w;}
virtual void setCharges(double c){ charges=c;}
virtual void setAnnintrate(double a){ annintrate=a;}
double getBalance(){ return balance;}
double getDnum(){ return dnum;}
double getWnum(){ return wnum;}
double getCharges(){ return charges;}
double getAnnintrate(){ return annintrate;}
};
class Saving : public Account
{
private:
bool status ;
public:
Saving();
void deposit(double);
void withdraw(double);
void MonthlyProc();
void setStatus(bool);
bool getStatus();
};
class checking : public Account
{
public:
checking();
void withdraw(double);
void monthlyProc();
};
//Account.cpp
#include "header.h"
using namespace std;
Account::Account()
{
}
Account::Account(double bal=200,double air=0.12)
{
balance=bal;
annintrate=air;
beginBal=bal;
}
void Account::deposit(double dep)
{
balance=balance+dep;
dnum++;
}
void Account::withdraw(double with)
{
balance=balance-with;
wnum++;
}
void Account::calcInt()
{
double MIR,MI;
MIR= annintrate / 12;
MI = balance * MIR;
balance = balance + MI;
}
void Account::monthlyProc()
{
balance=balance-charges;
calcInt();
wnum=0;
dnum=0;
charges=0;
}
//saving.cpp
#include "header.h"
#include <iostream>
using namespace std;
Saving::Saving()
{
}
void Saving::deposit(double d)
{
if (balance+d > 25.0)
{
setStatus(true);
cout <<"\nthanks your deposit will make your account active."<<endl;
}
else
{
setStatus(false);
cout <<"\nSorry your depositing will not make the account active."<<endl;
}
Account::deposit(d);
}
void Saving::withdraw(double w)
{
if (balance >= 25)
{
setStatus(true);
}
else
{
setStatus(false);
}
}
void Saving::MonthlyProc()
{
if(wnum>4)
{
charges=1;
}
//checking::monthlyProc();
}
void Saving::setStatus(bool tf)
{
status=tf;
}
bool Saving::getStatus()
{
return status;
}
//checking.cpp
#include "header.h"
#include <iostream>
using namespace std;
checking::checking()
{
}
void checking::withdraw(double w)
{
double with=w;
if(balance-wnum<0)
{
charges=15;
balance=balance-charges;
if(balance-charges<0)
cout<<"you have to pay "<<charges-balance<<" to the bank.";
}
Account::withdraw(with);
}
void checking::monthlyProc()
{
charges=charges+(5+0.10);
Account::monthlyProc();
}
//main.cpp
#include <iostream>
using namespace std;
class Account
{
protected:
double beginBal;
double balance;
double dnum;
double wnum;
double charges;
double annintrate;
public:
Account(double bal=200,double air=0.12)
{
balance=bal;
annintrate=air;
beginBal=bal;
}
virtual deposit(double dep)
{
balance=balance+dep;
dnum++;
}
virtual withdraw(double with)
{
balance=balance-with;
wnum++;
}
virtual void calcInt();
virtual void monthlyProc();
virtual void setBalance(double bal){ balance=bal;}
virtual void setDnum(double d){ dnum=d;}
virtual void setWnum(double w){ wnum=w;}
virtual void setCharges(double c){ charges=c;}
virtual void setAnnintrate(double a){ annintrate=a;}
double getBalance(){ return balance;}
double getDnum(){ return dnum;}
double getWnum(){ return wnum;}
double getCharges(){ return charges;}
double getAnnintrate(){ return annintrate;}
};
class Saving : public Account
{
private:
bool status ;
public:
Saving();
void deposit(double);
void withdraw(double);
void MonthlyProc();
void setStatus(bool);
bool getStatus();
};
class checking : public Account
{
public:
checking();
void withdraw(double);
void monthlyProc();
};
in saving.cpp in function deposit
void Saving::deposit(double d)
{
if (balance+d > 25.0)
{
setStatus(true);
cout <<"\nthanks your deposit will make your account active."<<endl;
}
else
{
setStatus(false);
cout <<"\nSorry your depositing will not make the account active."<<endl;
}
Account::deposit(d);
}
cannot do (balance + d)
i think it cannot read balance but i dont knoe why because class saving is inharited to the base class