#include "BankAccount.h" #include "CheckingAccount.h" #include "SavingsAccount.h" #include using std::cout; int main(int argc, char* argv[]) { BankAccount b1("Ralph"), b2("Ann", 27.51); CheckingAccount c1("Jack", 1000, 800, 0.06, 15.00); CheckingAccount c2("Lisa", 450); CheckingAccount c3("Andy", 750, 20, 0.57, 120.00); CheckingAccount c4(c3); CheckingAccount c5(c3); c4.setAccountNumber("Alice"); c5 = c2; c5.setAccountNumber("Maxwell"); SavingsAccount s1("Samir", 9300); SavingsAccount s2("Rita", 32); cout << "Initial bank accounts ****\n"; cout << b1 << '\n'; cout << b2 << '\n'; cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; cout << c4 << '\n'; cout << c5 << '\n'; cout << s1 << '\n'; cout << s2 << '\n'; cout << "\nBank accounts so far: " << BankAccount::getCount() << '\n'; { SavingsAccount s3(s2); cout << "\nAfter creating another: " << BankAccount::getCount() << '\n'; } cout << "\nAnd then deleting one: " << BankAccount::getCount() << '\n'; cout << "\nAfter changing accounts:\n"; b1.setAccountNumber("Melvin"); b1.withdraw(50.00); c3.setInterestRate(c3.getInterestRate() - 0.50); c3.setServiceCharge(c3.getServiceCharge() - 110.00); c3.setMinimumBalance(c3.getMinimumBalance() + 580.00); s2.setInterestRate(s2.getInterestRate() + 0.05); cout << b1 << '\n'; cout << c3 << '\n'; cout << s2 << '\n'; cout << "\nAfter posting interest *****\n"; c1.postInterest(); c2.postInterest(); c3.postInterest(); s1.postInterest(); s2.postInterest(); cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; cout << s1 << '\n'; cout << s2 << '\n'; cout << "\nTrying to do withdrawals:\n"; double amtc1 = 250.00, amtc2 = 300.00, amtc3 = 100.00; double amts1 = 120.00, amts2 = 290.00; cout << c1.getAccountNumber() << "'s account "; cout << (c1.verifyMinimumBalance(amtc1) ? "has sufficient funds\n" : "will go below the minimum balance\n"); cout << c2.getAccountNumber() << "'s account "; cout << (c2.verifyMinimumBalance(amtc2) ? "has sufficient funds\n" : "will go below the minimum balance\n"); cout << c3.getAccountNumber() << "'s account "; cout << (c3.verifyMinimumBalance(amtc3) ? "has sufficient funds\n" : "will go below the minimum balance\n"); c1.writeCheck(amtc1); c2.writeCheck(amtc2); c3.writeCheck(amtc3); s1.withdraw(amts1); s2.withdraw(amts2); cout << "\nAfter withdrawing money *****\n"; cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; cout << s1 << '\n'; cout << s2 << '\n'; cout << "\nTrying to do a couple more withdrawals:\n"; if (c1.withdraw(150.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $150.00 from " << c1.getAccountNumber() << "'s account\n"; if (c1.withdraw(50.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $50.00 from " << c1.getAccountNumber() << "'s account\n"; if (c2.writeCheck(50.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $50.00 from " << c2.getAccountNumber() << "'s account\n"; if (c3.writeCheck(105.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $105.00 from " << c3.getAccountNumber() << "'s account\n"; if (c3.writeCheck(800.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $800.00 from " << c3.getAccountNumber() << "'s account\n"; cout << "\nAfter final withdrawals *****\n"; cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; return 0; }