main
-----
line 10: You define MyAccountInfo, but you never reference it.
line 12: You want to pass MyAccountInfo to MainMenu as a parameter.
functions
---------
line 5: You define MyBankArray as a local array. It goes out of scope when CreateAccount exists.
line 14: You're storing data into the local array, but the data will be lost when the local array goes out of scope.
line 23: You reference MyBankArray, but MyBankArray is not in scope.
line 43: Why are you declaring myBankData? You don't reference it.
line 44: Why does StoreData call MainMenu? Calling a menu has nothing to do with storing data.
line 58: You cin DepositAmount to a local variable, but don't do anything with it.
line 66: Ditto for WithdrawalAmount.
menu
-----
line 9: Why are you declaring MyBankArray as a local array. Again, it's going to go out of scope when MainMenu exits.
edit:
Here's a cleanup of your code. It compiles, but has not been tested.
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
|
#include <string>
#include <iostream>
#include <cstdlib>
// #include "Assignment2.h"
using namespace std;
class BankAccount
{ string AccountHolder;
int AccountNumber;
long double Balance;
long double InterestRate;
public:
void CreateAccount();
void StoreData (const string &, int, long double);
void PrintCustomerData();
void Deposit();
void Withdrawal();
};
void CreateAccount(BankAccount accts[], int & numaccts)
{ int AccountNumber = 0, index = 0;
long double Balance = 50.0;
string AccountHolder;
cout << "Enter Account Holders Name" << endl;
cin >> AccountHolder;
cout << "Congratulations....Your NEW Pro-Bank Extreme account has been successfully created..." << endl;
cout << "As a bonus for opening a new account, a $50.00 credit has been automatically deposited into your new account!!" << endl;
cout << "Your Pro-Bank Extreme account number is : " << AccountNumber << endl;
accts[numaccts].StoreData (AccountHolder, AccountNumber, Balance);
numaccts++;
}
void PrintData (BankAccount accts[], int numaccts)
{ for (int index = 0; index < numaccts; ++index)
{ accts[index].PrintCustomerData();
}
}
int CreateAccountNumber()
{ static int AccountNumber = 0;
return ++AccountNumber;
}
void BankAccount::StoreData (const string & AcctHolder, int AcctNumber, long double Bal)
{ long double IntRate = 10.0;
AccountHolder = AcctHolder;
AccountNumber = AcctNumber;
Balance = Bal;
InterestRate = IntRate;
BankAccount MyBankData;
}
void BankAccount::PrintCustomerData ()
{ cout << "Primary Account Holder Name :" << AccountHolder << endl;
cout << "Pro-Bank Extreme Account Number :" << AccountNumber << endl;
cout << "Current Balance :" << Balance << endl;
cout << "Interest Rate :" << InterestRate << endl;
}
void BankAccount::Deposit()
{ long double DepositAmount;
cout << "Enter Deposit Ammount :" << endl;
cin >> DepositAmount;
Balance += DepositAmount;
}
void BankAccount::Withdrawal()
{ long double WithdrawalAmount;
cout << "Enter Withdrawal Ammount :" << endl;
cin >> WithdrawalAmount;
if (WithdrawalAmount > Balance)
{ cout << "Widthdrawal exceeeds balance" << endl;
return;
}
Balance -= WithdrawalAmount;
}
void MainMenu (BankAccount accts[], int numaccts)
{ int Choice;
bool quit = false;
while (!quit)
{ cout << "== MAIN MENU ==" << endl;
cout << "1. ADD a customer" << endl;
cout << "2. Print ALL customer data for ALL customers" << endl;
cout << "3. UPDATE existing customer DATA" << endl;
cout << "4. EXIT" << endl;
cout << "Enter a menu choice: " << endl;
cin >> Choice;
cout << endl;
switch(Choice)
{
case 1: CreateAccount (accts, numaccts); //replace "Add a customer with CreateAccountNumber Function here
break;
case 2: PrintData (accts, numaccts);
break;
case 3: cout << "UPDATE existing customer DATA: " << endl;
cout << "a) Make a Deposit: " << endl;
//(Deposit)
cout << "b) Withdrawal: " << endl;
//(Withdrawal)
cout << "c) Print Account Balance: " << endl;
//(PrintAccountBallance)
cout << "d) Update Account Balance WITH interest: " << endl;
//(UpdateAccountBalance)
cout << "e) Exit to Main Menu" << endl;
//(ExitToMainMenu)
break;
case 4: cout << "EXIT" << endl;
quit = true;
break;
}
}
}
int main()
{ BankAccount MyAccountInfo[100];
int numaccts = 0;
cout << "*****Pro-Bank Extreme*****" << endl;
MainMenu (MyAccountInfo, numaccts);
system ("pause");
return 0;
}
|