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
|
#include <iostream>
#include<string>
#include<fstream>
using namespace std;
int createAccount(string customerName, int checkingBalance, int savingsBalance);
int main() {
int checkingBalance = 0;
int savingsBalance = 0;
string customerName;
cout << "Welcome!" << endl << "Enter your name: ";
cin >> customerName;
createAccount(customerName,checkingBalance,savingsBalance);
return 0;
}
int createAccount(string customerName,int checkingBalance, int savingsBalance){
char infoChoice = 'x';
char checkingChoice, savingsChoice;
int checkingDeposit, checkingWithdrawl, savingsDeposit, savingsWithdrawl;
string historyFileName = customerName + " History";
ofstream customerHistoryFile(historyFileName.c_str());
while(infoChoice != 'e'){
cout << "Account created!" << endl << "if you would like to view your checking account press c, for savings press s, and for a transaction history press h, press e to exit" << endl;
cin >> infoChoice;
if(infoChoice == 'c'){
cout << "Would you like to deposit, withdraw, or view your balance?" << endl << "d to deposit, w to withdraw, and b for balance.";
cin >> checkingChoice;
if(checkingChoice == 'd'){
cout << "How much would you like to deposit?" << endl;
cin >> checkingDeposit;
checkingBalance = checkingBalance + checkingDeposit;
customerHistoryFile.open(historyFileName.c_str(), ios::ate | ios::in);
customerHistoryFile << "You deposited: " << checkingDeposit << " dollar(s).";
customerHistoryFile.close();
}
else if(checkingChoice == 'w'){
cout << "How much would you like to withdraw?" << endl;
cin >> checkingWithdrawl;
checkingBalance = checkingBalance - checkingWithdrawl;
customerHistoryFile.open(historyFileName.c_str(), ios::ate| ios::in);
if(customerHistoryFile.is_open()){
customerHistoryFile << "You withdrew: " << checkingWithdrawl << " dollar(s)" << endl;
}
customerHistoryFile.close();
}
else if(checkingChoice == 'b'){
cout << checkingBalance;
}
}
}
}
|