Banks offer various types of accounts such as savings checki
Solution
#include <iostream>
#include <string>
using namespace std;
class bankAccount
{
private:
string accHolderName;
string accountType;
int accountNumber;
double accBalance;
public:
bankAccount(string fullName = \"\", string accType = \"\", int accNum = 0, double balance = 0.0);
string getAccHolderName() const;
string getAccountType() const;
int getAccountNumber() const;
double getAccBalance() const;
void deposit(double amount);
void withdrawl(double amount);
virtual void print() const = 0;
};
/*contructor*/
bankAccount::bankAccount(string fullName, string accType, int accNum, double balance) {
accHolderName = fullName;
accountType = accType;
accountNumber = accNum;
accBalance = balance;
}
string bankAccount::getAccHolderName() const{
return accHolderName;
}
string bankAccount::getAccountType() const{
return accountType;
}
int bankAccount::getAccountNumber() const{
return accountNumber;
}
double bankAccount::getAccBalance() const{
return accBalance;
}
void bankAccount::deposit(double amount) {
accBalance += amount;
}
void bankAccount::withdrawl(double amount) {
if (amount > accBalance) {
cout << \"Insufficent Funds. Account balance: \" << accBalance << endl;
} else {
accBalance -= amount;
}
}
class checkingAccount: public bankAccount
{
private:
int numOfChecks;
public:
checkingAccount(string fullName = \"\", string accType = \"\", int accNum = 0, double balance = 0.0, int numChecks = 10);
int getChecksAvailable() const;
/*pure virtual function*/
virtual void writeCheck() = 0;
};
/*constructor*/
checkingAccount::checkingAccount(string fullName, string accType, int accNum, double balance, int numChecks)
:bankAccount(fullName, accType, accNum, balance) {
numOfChecks = numChecks;
}
int checkingAccount::getChecksAvailable() const {
return numOfChecks;
}
class serviceChargeChecking: public checkingAccount
{
private:
double minBalance;
double intRate;
public:
serviceChargeChecking(string fullName = \"\", string accType = \"Service Charge Checking\", int accNum = 0, double balance = 0.0, int numChecks = 10, double mBalance = 10.0, double iRate = .01);
void writeCheck();
double getIntRate() const;
void print() const;
};
/*constructor*/
serviceChargeChecking::serviceChargeChecking(string fullName, string accType, int accNum, double balance, int numChecks, double mBalance, double iRate)
:checkingAccount(fullName, accType, accNum, balance, numChecks) {
minBalance = mBalance;
intRate = iRate;
}
void serviceChargeChecking::writeCheck() {
}
double serviceChargeChecking::getIntRate() const {
return intRate;
}
void serviceChargeChecking::print() const {
cout << \"Account Number: \" << getAccountNumber() << endl;
cout << \"Account Type: \" << getAccountType() << endl;
cout << \"Name: \" << getAccHolderName() << endl;
cout << \"Balance: \" << getAccBalance() << endl;
cout << \"Interest Rate: \" << getIntRate() << endl;
cout << \"Remaining Checks: \" << getChecksAvailable() << endl;
}
class noServiceChargeChecking: public checkingAccount
{
private:
public:
};
class highInterestChecking: public checkingAccount
{
private:
public:
};
class savingsAccount: public bankAccount
{
private:
public:
};
class highInterestSavings: public savingsAccount
{
private:
public:
};
class certificateOfDeposit: public bankAccount
{
private:
public:
};
int main() {
/*testing*/
serviceChargeChecking myAccount(\"David Flores\", \"Service Charge Checking\", 12, 1000.25, 10, 10.0, .01);
myAccount.print();
return 0;
}
bankAccount.h
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
#include <string>
using namespace std;
class bankAccount
{
public:
//accessors
string getName(); //grabs first name, spaces will end the program
long getAccountNum(); //grabs account #
double getBalance(); //grabs balance
double getWithdraw(); //grabs withdrawal amount
//mutators
void setName(string newName); //sets up the name
void setAccountNum(long newAccountNum); //sets up the account #
void setBalance(double newBalance); //sets up the balance
void setDepositAmt(double newDepositAmt); //captures the deposit amt
void setWithdrawAmt(double newWithdrawAmt); //captures the w/drawal amt
//other functions
virtual void printStatement() = 0; //prints the monthly statement aka declared in later classes since each class\'s statements are different
void calcDepBal(); //calcs new balance after depositing
virtual void calcWithBal(); //calcs new balance after withdrawal but will be overwritten by derived classes for its specific purpose
virtual void withdrawing(); //does the process of withdrawing, all the w/drawing will be done here by derived classes for its specific purpose
void depositing(); //does the process of depositing, all the depositing will be done here
private:
string name; //ex: Maria
long accountNum; //ex: 100194 <-bad account num
double balance; //ex: 500.00
double deposit; //ex: 20 or 20.00
double withdraw; //ex: 20 or 20.00
};
#endif // !BANKACCOUNT_H
bankAccount.cpp
#include \"bankAccount.h\"
#include <iostream>
#include <string>
using namespace std;
//accessors
string bankAccount::getName() //grabs first name
{
return name; //this will grab the name and output it
} //end getName
long bankAccount::getAccountNum() //grabs account #
{
return accountNum; //this grabs the account # and outputs it
} //end accountNum
double bankAccount::getBalance() //grabs balance
{
return balance; //this grabs the balance amount and outputs it
} //end getBalance
double bankAccount::getWithdraw() //grabs withdrawal amount
{
return withdraw; //this grabs the amount the user decides to withdraw
} //end getWithdraw
//mutators
void bankAccount::setName(string newName) //sets up the name
{
name = newName; //the string in the setName will be assigned to the variable: name
} //end setName
void bankAccount::setAccountNum(long newAccountNum) //sets up the account #
{
accountNum = newAccountNum; //the long in setAccountNum will be assigned to the variable: accountNum
} //end setAccountNum
void bankAccount::setBalance(double newBalance) //sets up the balance
{
balance = newBalance; //the double variable in setBalance will be assigned to the variable: balance
} //end setBalance
void bankAccount::setDepositAmt(double newDepositAmt) //captures the deposit amt
{
deposit = newDepositAmt; //the double variable in the setDepositAmt will be assigned to the variable: deposit
} //setDepositAmt
void bankAccount::setWithdrawAmt(double newWithdrawAmt) //captures the w/drawal amt
{
withdraw = newWithdrawAmt; //the double variable in the setWithdrawAmt will be assigned to the variable: withdraw
} //end endWithdrawAmt
//other functions
void bankAccount::calcDepBal() //calcs new balance after depositing
{
bankAccount::setBalance(balance + deposit); //calcs the new balance by adding the deposit to the current balance
} //end calcDepBal
void bankAccount::calcWithBal() //calcs new balance after withdrawal
{
if (balance > withdraw)
bankAccount::setBalance(balance - withdraw); //calcs the new balance by subtracting the withrawal amt to the current balance
//only if the current balance is higher than the withdrawal amt since it the balance can\'t be a negative number
else
cout << \"Withdrawal denied \ \ \"; //if the withdrawal amt is higher than the current balance then it will not withdraw
} //end calcWithBal
void bankAccount::withdrawing() //does the process of withdrawing
{
cout << \"How much would you like to withdraw?: \";
cin >> withdraw;
bankAccount::setWithdrawAmt(withdraw);
cout << \"Withdrawing... \ \";
bankAccount::calcWithBal();
cout << \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
} //end withdrawing
void bankAccount::depositing() //does the process of depositing
{
cout << \"How much would you like to deposit?: \";
cin >> deposit;
bankAccount::setDepositAmt(deposit);
bankAccount::calcDepBal();
cout << \"Depositing... \ \"
<< \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
} //end depositing
certificateOfDeposit.h
#ifndef CERTIFICATEOFDEPOSIT_H
#define CERTIFICATEOFDEPOSIT_H
#include \"bankAccount.h\"
#include <string>
using namespace std;
class certificateOfDeposit : public bankAccount
{
public:
//accessors
//remember: accessors from bankAccount will be accessed
//mutators
//remember: mutators from bankAccount will be accessed
//constructor with default parameters
//upon instatiating, these parameters will be created
certificateOfDeposit(string dName = \"\", long dAccountNumber = 0, double dBalance = 530.50, double dDepositAmt = 0, double dWithdrawAmt = 0);
//other functions
//remember: other fumctions from bankAccount will be accessed
void printStatement(); //prints the monthly statement for this specific class
private:
const double INTEREST = 0.021; //interest of CD is 2.1%
const int NUMOFMATMONTH = 24; //total number of maturity months are 24
int currentMonth = 3; //current month of CD is the 3rd
};
#endif // !CERTIFICATEOFDEPOSIT_H
certificateOfDeposit.cpp
#include \"certificateOfDeposit.h\"
#include <iostream>
#include <string>
using namespace std;
//constructor with default parameters
//upon instatiating, these parameters will be created
certificateOfDeposit::certificateOfDeposit(string dName, long dAccountNumber, double dBalance, double dDepositAmt, double dWithdrawAmt)
{
bankAccount::setName(dName);
bankAccount::setAccountNum(dAccountNumber);
bankAccount::setBalance(dBalance);
bankAccount::setDepositAmt(dDepositAmt);
bankAccount::setWithdrawAmt(dWithdrawAmt);
} //end certificateOfDeposit
//other functions
void certificateOfDeposit::printStatement() //prints the monthly statement for this specific class
{
cout << \"------------------------------------------- \ \"
<< \"\\t Certificate of Deposit \ \ \"
<< \"Name: \\t\\t\\t\\t\" << bankAccount::getName() << \"\ \"
<< \"Account Number: \\t\\t\" << bankAccount::getAccountNum() << \"\ \"
<< \"Current Balance: \\t\\t\" << bankAccount::getBalance() << \"\ \"
<< \"No minimum balance \ \"
<< \"Interest: \\t\\t\\t\" << INTEREST << \"\ \"
<< \"Number of maturity months: \\t\" << NUMOFMATMONTH << \"\ \"
<< \"Current maturity month: \\t\" << currentMonth << \"\ \"
<< \"------------------------------------------- \ \ \";
} //end printStatement
checkingAccount.h
#ifndef CHECKINGACCOUNT_H
#define CHECKINGACCOUNT_H
#include \"bankAccount.h\"
#include <string>
using namespace std;
class checkingAccount : public bankAccount
{
public:
//accessors
//remember: accessors from bankAccount will be accessed
double getCheck(); //gets the check total amt
string getCheckRec(); //gets the name of the check\'s recepient who the client wants to make the check to
//mutators
//remember: mutators from bankAccount will be accessed
void setCheck(double newCheckAmt); //sets up the check total
void setCheckRec(string newCheckRec); //sets the name of the check\'s recipient
//other functions
virtual void writeCheck() = 0; //prompts for recepient & total. creates new balance. declared in later classes since each class is different
private:
double checkAmt; //ex: 23.00 or 23
string checkRec; //ex: Rachel
};
#endif // !CHECKINGACCOUNT_H
checkingAccount.cpp
#include \"checkingAccount.h\"
#include <iostream>
#include <string>
using namespace std;
//accessors
//remember: accessors from bankAccount will be accessed
double checkingAccount::getCheck() //gets the check total
{
return checkAmt; //outputs the total amount of what the check is
} //end getCheck
string checkingAccount::getCheckRec() //gets the name of the check\'s recepient
{
return checkRec; //outputs the name of the person the client made the check to
} //end getCheckRec
//mutators
//remember: mutators from bankAccount will be accessed
void checkingAccount::setCheck(double newCheckAmt) //sets up the check total
{
checkAmt = newCheckAmt; //double variable in setCheck will be assigned to the variable: checkAmt
} //end setCheck
void checkingAccount::setCheckRec(string newCheckRec) //sets the name of the check\'s recipient
{
checkRec = newCheckRec; //double variable in setCheckRec will be assigned to the variable: checkRec
} //end setCheckRec
highInterestChecking.h
#ifndef HIGHINTERESTCHECKING_H
#define HIGHINTERESTCHECKING_H
#include \"noServiceChargeChecking.h\"
#include <string>
using namespace std;
class highInterestChecking : public noServiceChargeChecking
{
public:
highInterestChecking(string dName = \"\", long dAccountNumber = 0, double dBalance = 850.00, double dDepositAmt = 0, double dWithdrawAmt = 0, string dCheckRec = \"\", double dCheckAmt = 0);
//other functions
//remember: other functions from bankAccount, checkingAccount, and noServiceChargeChecking will be accessed
void printStatement(); //prints the monthly statement for this class specifically
void writeCheck(); //prompts for recepient & total. creates new balance. for this specific class
void calcWithBal(); //calcs new balance after withdrawal for this specific class
void withdrawing(); //does the process of withdrawing for this specific class
private:
const double MINIMUM_BALANCE = 550.00;
const double INTEREST = 0.10;
string newName; //ex: Maria
double newCheckAmt; //ex: 20 or 20.00
double withdraw; //ex: 20.00 or 20
};
#endif // !HIGHINTERESTCHECKING_H
highInterestChecking.cpp
#include \"highInterestChecking.h\"
#include <iostream>
#include <string>
using namespace std;
//constructor with default parameters
//upon instatiating, these parameters will be created
highInterestChecking::highInterestChecking(string dName, long dAccountNumber, double dBalance, double dDepositAmt, double dWithdrawAmt, string dCheckRec, double dCheckAmt)
{
bankAccount::setName(dName);
bankAccount::setAccountNum(dAccountNumber);
bankAccount::setBalance(dBalance);
bankAccount::setDepositAmt(dDepositAmt);
bankAccount::setWithdrawAmt(dWithdrawAmt);
checkingAccount::setCheckRec(dCheckRec);
checkingAccount::setCheck(dCheckAmt);
} //end highInterestChecking
//other functions
void highInterestChecking::printStatement() //prints the monthly statement for this specific class
{
cout << \"------------------------------------------------------------------------------- \ \"
<< \"\\t Checking account with no service charge and high interest \ \ \"
<< \"Name: \\t\\t\\t\\t\" << bankAccount::getName() << \"\ \"
<< \"Account Number: \\t\\t\" << bankAccount::getAccountNum() << \"\ \"
<< \"Current Balance: \\t\\t\" << bankAccount::getBalance() << \"\ \"
<< \"Total checks per month: \\tunlimited \ \"
<< \"Interest: \\t\\t\\t\" << INTEREST << \"\ \"
<< \"Minimum balance: \\t\\t\" << MINIMUM_BALANCE << \"\ \"
<< \"Monthly charge: \\t\\tno \ \"
<< \"------------------------------------------------------------------------------- \ \ \";
} //end printStatement
void highInterestChecking::writeCheck() //prompts for recepient & total. creates new balance. for this specific class
{
cout << \"Name of the recepient: \";
cin >> newName;
checkingAccount::setCheckRec(newName);
cout << \"Check total: \";
cin >> newCheckAmt;
checkingAccount::setCheck(newCheckAmt);
cout << \"Creating check... \ \";
if (bankAccount::getBalance() > checkingAccount::getCheck())
{
bankAccount::setBalance(bankAccount::getBalance() - checkingAccount::getCheck()); //makes sure that the balance doesn\'t fall in the (-)s
if (bankAccount::getBalance() < MINIMUM_BALANCE) //makes sure that the balance doesn\'t full under mini balance
{
bankAccount::setBalance(bankAccount::getBalance() + checkingAccount::getCheck());
cout << \"Check denied: passing minimal balance \ \ \";
} //end if
else
{
cout << \"Success! \ \"
<< \"Recepient: \\t\" << checkingAccount::getCheckRec() << \"\ \"
<< \"Check total: \\t\" << checkingAccount::getCheck() << \"\ \";
} //end else
} //end if
else
cout << \"Check denied \ \ \";
cout << \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
} //end writeCheck()
void highInterestChecking::calcWithBal() //calcs new balance after withdrawal for this specific class
{
if (bankAccount::getBalance() > bankAccount::getWithdraw()) //makes sure that the balance doesn\'t fall in the (-)s
{
bankAccount::setBalance(bankAccount::getBalance() - bankAccount::getWithdraw());
if (bankAccount::getBalance() < MINIMUM_BALANCE)//makes sure that the balance doesn\'t full under mini balance
{
bankAccount::setBalance(bankAccount::getBalance() + bankAccount::getWithdraw());
cout << \"Withrawal denied: passing minimal balance of: \" << MINIMUM_BALANCE << \"\ \ \";
} //end if
} //end if
else
cout << \"Withdrawal denied \ \ \";
}
void highInterestChecking::withdrawing() //does the process of withdrawing for this specific class
{
cout << \"How much would you like to withdraw?: \";
cin >> withdraw;
bankAccount::setWithdrawAmt(withdraw);
cout << \"Withdrawing... \ \";
highInterestChecking::calcWithBal();
cout << \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
}
highInterestSavings.h
#ifndef HIGHINTERESTSAVINGS_H
#define HIGHINTERESTSAVINGS_H
#include \"savingsAccount.h\"
#include <string>
using namespace std;
//minimum balance
class highInterestSavings : public savingsAccount
{
public:
//constructor with default parameters
//upon instatiating, these parameters will be created
highInterestSavings(string dName = \"\", long dAccountNumber = 0, double dBalance = 630.50, double dDepositAmt = 0, double dWithdrawAmt = 0);
//other functions
//remember: other functions from bankAccount and savingsAccount will be accessed
void printStatement(); //prints the monthly statement for this specific class
void calcWithBal(); //calcs new balance after withdrawal for this specific class
void withdrawing(); //does the process of withdrawing for this specific class
private:
const double MINIMUM_BALANCE = 300.00;
const double INTEREST = 0.20;
double withdraw; //ex: 20 or 20.00
};
#endif // !HIGHINTERESTSAVINGS_H
highInterestSavings.cpp
#include \"highInterestSavings.h\"
#include <iostream>
#include <string>
using namespace std;
//constructor with default parameters
//upon instatiating, these parameters will be created
highInterestSavings::highInterestSavings(string dName, long dAccountNumber, double dBalance, double dDepositAmt, double dWithdrawAmt)
{
bankAccount::setName(dName);
bankAccount::setAccountNum(dAccountNumber);
bankAccount::setBalance(dBalance);
bankAccount::setDepositAmt(dDepositAmt);
bankAccount::setWithdrawAmt(dWithdrawAmt);
}
//other functions
void highInterestSavings::printStatement() //prints the monthly statement for this specific class
{
cout << \"---------------------------------------------------- \ \"
<< \"\\t Savings account with high interest \ \ \"
<< \"Name: \\t\\t\\t\\t\" << bankAccount::getName() << \"\ \"
<< \"Account Number: \\t\\t\" << bankAccount::getAccountNum() << \"\ \"
<< \"Current Balance: \\t\\t\" << bankAccount::getBalance() << \"\ \"
<< \"Interest: \\t\\t\\t\" << INTEREST << \"\ \"
<< \"Minimum balance: \\t\\t\" << MINIMUM_BALANCE << \"\ \"
<< \"---------------------------------------------------- \ \ \";
}
void highInterestSavings::calcWithBal() //calcs new balance after withdrawal for this specific class
{
if (bankAccount::getBalance() > bankAccount::getWithdraw()) //makes sure that the balance doesn\'t fall in the (-)s
{
bankAccount::setBalance(bankAccount::getBalance() - bankAccount::getWithdraw());
if (bankAccount::getBalance() < MINIMUM_BALANCE) //makes sure that the balance doesn\'t full under mini balance
{
bankAccount::setBalance(bankAccount::getBalance() + bankAccount::getWithdraw());
cout << \"Withrawal denied: passing minimal balance of: \" << MINIMUM_BALANCE << \"\ \ \";
} //end if
} //end if
else
cout << \"Withdrawal denied \ \ \";
}
void highInterestSavings::withdrawing() //does the process of withdrawing for this specific class
{
cout << \"How much would you like to withdraw?: \";
cin >> withdraw;
bankAccount::setWithdrawAmt(withdraw);
cout << \"Withdrawing... \ \";
highInterestSavings::calcWithBal();
cout << \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
}
noServiceChargeChecking.h
#ifndef NOSERVICECHARGECHECKING_H
#define NOSERVICECHARGECHECKING_H
#include \"checkingAccount.h\"
#include <string>
class noServiceChargeChecking : public checkingAccount
{
public:
//accessors
//remember: accessors from checkingAccount and bankAccount are accessed
//mutators
//remember: mutators from checkingAccount and bankAccount are accessed
//constructor with default parameters
//upon instatiating, these parameters will be created
noServiceChargeChecking(string dName = \"\", long dAccountNumber = 0, double dBalance = 650.50, double dDepositAmt = 0, double dWithdrawAmt = 0, string dCheckRec = \"\", double dCheckAmt = 0);
//other functions
void printStatement(); //prints the monthly statement
void writeCheck(); //prompts for recepient & total. creates new balance. for this specific clas
void calcWithBal(); //calcs new balance after withdrawal for this specific clas
void withdrawing(); //does the process of withdrawing for this specific clas
private:
const double MINIMUM_BALANCE = 350.00;
const double INTEREST = 0.01;
string newName; //ex: Maria
double newCheckAmt; //ex: 60.00 or 60
double withdraw; //ex: 70 or 70.00
}; //end class
#endif // !NOSERVICECHARGECHECKING_H
noServiceChargeChecking.cpp
#include \"noServiceChargeChecking.h\"
#include <iostream>
#include <string>
using namespace std;
//constructor with default parameters
//upon instatiating, these parameters will be created
noServiceChargeChecking::noServiceChargeChecking(string dName, long dAccountNumber, double dBalance, double dDepositAmt, double dWithdrawAmt, string dCheckRec, double dCheckAmt)
{
bankAccount::setName(dName);
bankAccount::setAccountNum(dAccountNumber);
bankAccount::setBalance(dBalance);
bankAccount::setDepositAmt(dDepositAmt);
bankAccount::setWithdrawAmt(dWithdrawAmt);
checkingAccount::setCheckRec(dCheckRec);
checkingAccount::setCheck(dCheckAmt);
} //end noServiceChargeChecking
//other functions
void noServiceChargeChecking::printStatement() //prints the monthly statement for this specific class
{
cout << \"---------------------------------------------------------- \ \"
<< \"\\t Checking account with no service charge \ \ \"
<< \"Name: \\t\\t\\t\\t\" << bankAccount::getName() << \"\ \"
<< \"Account Number: \\t\\t\" << bankAccount::getAccountNum() << \"\ \"
<< \"Current Balance: \\t\\t\" << bankAccount::getBalance() << \"\ \"
<< \"Total checks per month: \\tunlimited \ \"
<< \"Interest: \\t\\t\\t\" << INTEREST << \"\ \"
<< \"Minimum balance: \\t\\t\" << MINIMUM_BALANCE << \"\ \"
<< \"Monthly charge: \\t\\tno \ \"
<< \"---------------------------------------------------------- \ \ \";
} //end printStatement
void noServiceChargeChecking::writeCheck() //prompts for recepient & total. creates new balance. for this class
{
cout << \"Name of the recepient: \";
cin >> newName;
checkingAccount::setCheckRec(newName);
cout << \"Check total: \";
cin >> newCheckAmt;
checkingAccount::setCheck(newCheckAmt);
cout << \"Creating check... \ \";
if (bankAccount::getBalance() > checkingAccount::getCheck()) //makes sure that the balance doesn\'t fall in the (-)s
{
bankAccount::setBalance(bankAccount::getBalance() - checkingAccount::getCheck());
if (bankAccount::getBalance() < MINIMUM_BALANCE) //makes sure that the balance doesn\'t full under mini balance
{
bankAccount::setBalance(bankAccount::getBalance() + checkingAccount::getCheck());
cout << \"Check denied: passing minimal balance \ \ \";
} //end if
else
{
cout << \"Success! \ \"
<< \"Recepient: \\t\" << checkingAccount::getCheckRec() << \"\ \"
<< \"Check total: \\t\" << checkingAccount::getCheck() << \"\ \";
} //end else
} //end if
else
cout << \"Check denied \ \ \";
cout << \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
} //end writeCheck()
void noServiceChargeChecking::calcWithBal() //calcs new balance after withdrawal
{
if (bankAccount::getBalance() > bankAccount::getWithdraw()) //makes sure that the balance doesn\'t fall in the (-)s
{
bankAccount::setBalance(bankAccount::getBalance() - bankAccount::getWithdraw());
if (bankAccount::getBalance() < MINIMUM_BALANCE) //makes sure that the balance doesn\'t full under mini balance
{
bankAccount::setBalance(bankAccount::getBalance() + bankAccount::getWithdraw());
cout << \"Withrawal denied: passing minimal balance of: \" << MINIMUM_BALANCE << \"\ \ \";
} //end if
} //end if
else
cout << \"Withdrawal denied \ \ \";
} //end calcWithBal
void noServiceChargeChecking::withdrawing() //does the process of withdrawing
{
cout << \"How much would you like to withdraw?: \";
cin >> withdraw;
bankAccount::setWithdrawAmt(withdraw);
cout << \"Withdrawing... \ \";
noServiceChargeChecking::calcWithBal(); //makes sures that a withdrawal won\'t take more than mini balance
cout << \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
} //end withdrawing
savingsAccount.h
#ifndef SAVINGSACCOUNT_H
#define SAVINGSACCOUNT_H
#include \"bankAccount.h\"
#include <string>
using namespace std;
//inherits from bankAccount
//pays interest
class savingsAccount : public bankAccount
{
public:
//accessors
//remember: accessors from bankAccount will be accessed
//mutators
//remember: mutators from bankAccount will be accessed
//constructor with default parameters
//upon instatiating, these parameters will be created
savingsAccount(string dName = \"\", long dAccountNumber = 0, double dBalance = 530.50, double dDepositAmt = 0, double dWithdrawAmt = 0);
//other functions
//remember: other functions from bankAccount will be accessed
virtual void printStatement(); //prints the monthly statement for this specific class
private:
const double INTEREST = 0.02;
};
#endif // !SAVINGSACCOUNT_H
savingsAccount.cpp
#include \"savingsAccount.h\"
#include <iostream>
#include <string>
using namespace std;
//constructor with default parameters
//upon instatiating, these parameters will be created
savingsAccount::savingsAccount(string dName, long dAccountNumber, double dBalance, double dDepositAmt, double dWithdrawAmt)
{
bankAccount::setName(dName);
bankAccount::setAccountNum(dAccountNumber);
bankAccount::setBalance(dBalance);
bankAccount::setDepositAmt(dDepositAmt);
bankAccount::setWithdrawAmt(dWithdrawAmt);
} //end savingsAccount
//other functions
void savingsAccount::printStatement() //prints the monthly statement for this specific class
{
cout << \"------------------------------------------- \ \"
<< \"\\t Savings account \ \ \"
<< \"Name: \\t\\t\\t\\t\" << bankAccount::getName() << \"\ \"
<< \"Account Number: \\t\\t\" << bankAccount::getAccountNum() << \"\ \"
<< \"Current Balance: \\t\\t\" << bankAccount::getBalance() << \"\ \"
<< \"Interest: \\t\\t\\t\" << INTEREST << \"\ \"
<< \"Minimum balance: \\t\\tno \ \"
<< \"------------------------------------------- \ \ \";
} //end printStatement
serviceChargeChecking.h
#ifndef SERVICECHARGECHECKING_H
#define SERVICECHARGECHECKING_H
#include \"checkingAccount.h\"
#include <string>
using namespace std;
class serviceChargeChecking : public checkingAccount
{
public:
//accessors
//remember: accessors from checkingAccount and bankAccount are accessed
int getTotalChecks(); //gets the amount of checks used
int getRemCheck(); //gets the remaining number of checks
//mutators
//remember: mutators from checkingAccount and bankAccount are accessed
//constructor with default parameters
//upon instatiating, these parameters will be created
serviceChargeChecking(string dName = \"\", long dAccountNumber = 0, double dBalance = 500.50, double dDepositAmt = 0, double dWithdrawAmt = 0, string dCheckRec = \"\", double dCheckAmt = 0);
//other functions
void printStatement(); //prints the monthly statement for this specific class
void writeCheck(); //prompts for recepient & total. creates new balance. for this specific class
private:
const int NUM_OF_CHECKS = 10; //only 10 checks can be written in a month
string newName; //ex: Maria
double newCheckAmt; //ex: 50.00 or 50
int totalChecks = 0; //amount of checks the user has used and will be increment after each usage
};
#endif // !SERVICECHARGECHECKING_H
serviceChargeChecking.cpp
#include \"serviceChargeChecking.h\"
#include <iostream>
#include <string>
using namespace std;
//accessors
int serviceChargeChecking::getTotalChecks() //gets the amount of checks used
{
return totalChecks; //outputs the total amount of checks that have been used
} //end getTotalChecks
int serviceChargeChecking::getRemCheck() //gets the remaining number of checks
{
return NUM_OF_CHECKS - serviceChargeChecking::getTotalChecks(); //outputs the total amount of checks client has
} //end getRemCheck
//constructor
//variables in the parameters can over write the defaults
serviceChargeChecking::serviceChargeChecking(string dName, long dAccountNumber, double dBalance, double dDepositAmt, double dWithdrawAmt, string dCheckRec, double dCheckAmt)
{
bankAccount::setName(dName);
bankAccount::setAccountNum(dAccountNumber);
bankAccount::setBalance(dBalance);
bankAccount::setDepositAmt(dDepositAmt);
bankAccount::setWithdrawAmt(dWithdrawAmt);
checkingAccount::setCheckRec(dCheckRec);
checkingAccount::setCheck(dCheckAmt);
} //end serviceChargeChecking
//other functions
void serviceChargeChecking::printStatement() //prints the monthly statement
{
cout << \"------------------------------------------------------ \ \"
<< \"\\t Checking account with service charge \ \ \"
<< \"Name: \\t\\t\\t\\t\" << bankAccount::getName() << \"\ \"
<< \"Account Number: \\t\\t\" << bankAccount::getAccountNum() << \"\ \"
<< \"Current Balance: \\t\\t\" << bankAccount::getBalance() << \"\ \"
<< \"Total checks per month: \\t\" << NUM_OF_CHECKS << \"\ \"
<< \"Total checks left: \\t\\t\" << serviceChargeChecking::getRemCheck() << \"\ \"
<< \"No interest \ \"
<< \"No minimum balance \ \"
<< \"------------------------------------------------------ \ \ \";
} //end printStatement
void serviceChargeChecking::writeCheck() //prompts for recepient & total. creates new balance.
{
//this will determine if the user has checks left to create one else it will deny them to write a check
if (totalChecks <= NUM_OF_CHECKS)
{
cout << \"Name of the recepient: \";
cin >> newName;
checkingAccount::setCheckRec(newName);
cout << \"Check total: \";
cin >> newCheckAmt;
checkingAccount::setCheck(newCheckAmt);
cout << \"Creating check... \ \";
if (bankAccount::getBalance() > checkingAccount::getCheck()) //makes sure that the balance doesn\'t fall in the (-)s
{
bankAccount::setBalance(bankAccount::getBalance() - checkingAccount::getCheck());
cout << \"Success! \ \"
<< \"Recepient: \\t\" << checkingAccount::getCheckRec() << \"\ \"
<< \"Check total: \\t\" << checkingAccount::getCheck() << \"\ \";
} //end if
else
cout << \"Check denied \ \ \"; //if (-) will deny it
cout << \"Balance: \\t\" << bankAccount::getBalance() << \"\ \ \";
totalChecks++; //increments to keep track of the amount of checks used
} //end if
else
cout << \"You no longer have checks \ \ \";
} //end writeCheck
















