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
|
#include <iostream>
#include <fstream>
#include "account.h"
#include "savings.h"
#include "checking.h"
using namespace std;
int menu(ofstream&);
void savings_deposit(ofstream&, Savings&);
void checking_deposit(ofstream&, Checking&);
void saving_withdraw(ofstream&, Savings&);
void checking_withdraw(ofstream&, Checking&);
void new_month(Checking&, Savings&);
int main(int argc, char * argv[])
{
if(!(argc > 1))
{
return 1;
}
Checking check(0.0, 0.05);
Savings save(0.0, 0.05);
ofstream ofile(argv[1], ios::out);
if(!(ofile.is_open()))
{
std::cout << "Error writing to file";
return 1;
}
ofile << "\n\n" << endl;
int proceed = menu(ofile);
if(proceed == 6)
return 0;
while(proceed != 6)
{
if(proceed == 1)
{
savings_deposit(ofile, save);
proceed = menu(ofile);
} else if(proceed == 2)
{
checking_deposit(ofile, check);
proceed = menu(ofile);
} else if(proceed == 3)
{
saving_withdraw(ofile, save);
proceed = menu(ofile);
} else if(proceed == 4)
{
checking_withdraw(ofile, check);
proceed = menu(ofile);
} else if(proceed == 5)
{
new_month(check, save);
proceed = menu(ofile);
}
}
ofile.close();
return 0;
}
int menu(ofstream &ofile)
{
ofile << " ******** BANK ACCOUNT MENU ******** " << endl;
ofile << "\n" << "1. Savings Account Deposit" << endl;
ofile << "2. Checking Account Deposit" << endl;
ofile << "3. Savings Account Withdrawal" << endl;
ofile << "4. Checking Account Withdrawal" << endl;
ofile << "5. Update and Display Account Statistics" << endl;
ofile << "6. Exit" << "\n" << endl;
ofile << "Your choice, please: (1-6)";
int choice;
cin >> choice;
return choice;
}
void savings_deposit(ofstream& ofile, Savings& save)
{
ofile << " Enter amount to deposit:" << endl;
double amount;
cin >> amount;
save.deposit(amount);
}
void checking_deposit(ostream& ofile, Checking& check)
{
ofile << " Enter amount to deposit: " << endl;
double amount;
cin >> amount;
check.deposit(amount);
}
void saving_withdraw(ostream& ofile, Savings& save)
{
ofile << "Enter amount to withdraw: " << endl;
double amount;
cin >> amount;
save.withdraw(amount);
}
void checking_withdraw(ofstream& ofile, Checking& check)
{
ofile << "Enter amount to withdraw: " << endl;
double amount;
cin >> amount;
check.withdraw(amount);
}
void new_month(Checking& check, Savings& save)
{
save.monthlyProc();
check.monthlyProc();
}
|