1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
#include <iostream>
#include <iomanip>
//#include <vector>
#include "bankAccount.h"
#include "savingsAccount.h"
#include "highInterestSavings.h"
#include "noServiceChargeChecking.h"
#include "serviceChargeChecking.h"
#include "highInterestChecking.h"
#include "certificateOfDeposit.h"
#include "checkingAccount.h"
void program(bankAccount *[]);
int getAccount(bankAccount *[], int);
/*
Account Types:
Bank Account
Checking
Service Charge Checking
Checking with no service charge
High Interest Checking
Certificate of Deposit
Savings
High Interest Savings
*/
using namespace std;
int main()
{
bankAccount *accountsList[6];
accountsList[0] = new savingsAccount("Bill", 10200, 2500);
accountsList[1] = new highInterestSavings("Susan", 10210, 2000);
accountsList[2] = new noServiceChargeChecking("John", 20100,3500);
accountsList[3] = new serviceChargeChecking("Ravi", 30100, 1800);
accountsList[4] = new highInterestChecking("Sheila", 20200, 6000);
accountsList[5] = new certificateOfDeposit("Hamid", 51001, 18000, 0.00075, 18);
cout << "Hello, here is a look into my program." << endl << endl;
cout << "Here are the 6 accounts initialized into our bank account system. This is using the virtual print method that uses the print method of each object's class individually : " << endl << endl;
for (int i = 0; i < 6; i++)
{
accountsList[i]->print();
cout << endl;
}
accountsList[0]->setCurrentMonth(0);
accountsList[0] ->withdraw(100);
accountsList[0]->withdraw(300);
accountsList[0]->withdraw(500);
accountsList[0]-> deposit(70);
//BILL////////////////////////////////////////////
cout << "In January, Bill went to the bank and withdrew $100, $300, and $500 and deposited $70. At the end of the month his balance was " << accountsList[0]->getBalance() << " and, therefore, his balance post interest was " << accountsList[0]->postInterest() << endl;
cout<< endl;
cout <<"He did some more transactions in February and March." << endl << endl << endl;
accountsList[0]->setCurrentMonth(1);
accountsList[0] ->deposit(75);
accountsList[0]->withdraw(20);
accountsList[0]->withdraw(100);
accountsList[0]-> deposit(500);
accountsList[0]->setCurrentMonth(2);
accountsList[0] ->withdraw(500);
accountsList[0]->deposit(40);
accountsList[0]->withdraw(50);
accountsList[0]-> deposit(200);
//SUSAN //////////////////////////////////////////////////
cout << "Susan has a high-interest savings account. She currently does not meed our minimum balance of $2,500, however. I will use dynamic casting to utilize the \"verify minimum balance\" function inside the highInterestSavings class to check the minimum balance and deposit more money. " << endl << endl;
highInterestSavings* A = static_cast<highInterestSavings*>(accountsList[1]);
if(A->verifyMinimumBalance())
{
accountsList[1]->deposit(500);
}
cout << endl << endl;
//RAVI //////////////////////////////////////////////////
cout << "Ravi has a service charge checking account. I will use dynamic casting once again to access the functions in his account. " << endl << endl;
serviceChargeChecking* B = static_cast<serviceChargeChecking*>(accountsList[3]);
cout << "He will write more than 5 checks and will be charged the service charge for exceeding the maximum amount of checks. He will also be charged each month the account service charge of $10. He does some more transactions as well each month." << endl;
B->writeCheck(100);
B->writeCheck(50);
B->writeCheck(20);
B->writeCheck(30);
B->writeCheck(10);
cout << endl << endl << endl;
B->setCurrentMonth(0);
B->postInterest();
B->setCurrentMonth(1);
B->postInterest();
B->setCurrentMonth(2);
B->postInterest();
accountsList[3]->setCurrentMonth(0);
accountsList[3]->deposit(500);
accountsList[3]->withdraw(300);
accountsList[3]->setCurrentMonth(1);
accountsList[3] -> withdraw(30);
accountsList[3]->setCurrentMonth(2);
accountsList[3]->withdraw(25);
accountsList[3]->withdraw(300);
accountsList[3]->deposit(10);
//HAMID //////////////////////////////////////////////////
cout << "Hamid has one of the more special accounts, a certificate of deposit account. He will receive interest each month he has the money in his account, and for the months he already has in his account, there will be a deposit into his account of the accrued interest. Like the other class constructors, I used default parameters so that any information that was missing would go to the default value. Since Hamid has a special interest rate, that was applied instead of the default value of .05. However, the default value of 6 months for the maturity months was used, since none was provided. Since his account has been with us for 18 months, he is able to get all his money from each session of 6 months. However, in January through February, he will not receive any money since it hasn't reached the maturity of 6 months." << endl << endl;
cout << "I will use dynamic casting to access the member function of the Certificate of Deposit class object." << endl << endl;
certificateOfDeposit* C = static_cast<certificateOfDeposit*>(accountsList[5]);
C->postInterest();
cout << "Hamid, along with the other clients of our bank account program performed other transactions. Here are their monthly statements and information for each month:" << endl << endl;
accountsList[5]->setCurrentMonth(0);
accountsList[5]->withdraw(30);
accountsList[5]->deposit(200);
//more accountsList[] transactions were here for other accounts
C->setCurrentCDMonth();
cout << endl << "-------------\nJanuary:\n-------------" << endl << endl;
for (int i = 0; i < 6; i++)
{
accountsList[i]->setCurrentMonth(0);
cout << accountsList[i]-> getName() << "'s monthly statement:" <<endl << endl;
accountsList[i]->createMonthlyStatement();
cout << endl;
cout << accountsList[i]-> getName() << "'s information:" << endl << endl;
accountsList[i]->print();
cout << endl << endl << endl;
}
C->setCurrentCDMonth();
cout << "\n-------------\nFebruary:\n-------------" << endl << endl;
for (int i = 0; i < 6; i++)
{
accountsList[i]->setCurrentMonth(1);
cout << accountsList[i]-> getName() << "'s monthly statement:" << endl << endl;
accountsList[i]->createMonthlyStatement();
cout << endl;
cout << accountsList[i]-> getName() << "'s information:" << endl << endl ;
accountsList[i]->print();
cout << endl << endl << endl;
}
C->setCurrentCDMonth();
cout << "\n-------------\nMarch:\n-------------" << endl << endl;
for (int i = 0; i < 6; i++)
{
accountsList[i]->setCurrentMonth(2);
cout << accountsList[i]-> getName() << "'s monthly statement:" << endl << endl ;
accountsList[i]->createMonthlyStatement();
cout << endl;
cout << accountsList[i]-> getName() << "'s information:" << endl << endl;
accountsList[i]->print();
cout << endl << endl << endl;
}
for(int i = 0; i < 6; i++) {
delete accountsList[i];
accountsList[i] = nullptr;
}
*accountsList = nullptr;
return 0;
}
|