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 231 232 233 234 235
|
#include "BankAccount.h"
#include <string>
#include <iostream>
//GROUP MEMBERS ROGER REYNOLDS AND LEIGHTON FORD
void run();
void menu();
BankAccount findaccount(int, BankAccount[], int);
BankAccount withdraw();
BankAccount deposit();
using namespace std;
int main()
{
run();
cin.get();
cin.get();
return 0;
}
void run()
{
const int size = 5;
int option, itemCount = 0;
BankAccount item;
BankAccount acntaccount[size];
int acnt_number;
do{
menu();
cin >> option;
switch (option)
{
case 1:
cout << "Enter Account Number ";
cin >> acnt_number;
findaccount(acnt_number, acntaccount, size).display();
item = withdraw();
break;
case 2:
cout << "Enter Account Number ";
cin >> acnt_number;
findaccount(acnt_number, acntaccount, size).display();
item = deposit();
break;
case 3:
cout << "End of Program.\n";
exit(0);
break;
default:
cout << "Invalid menu option entered ..." << endl;
break;
}
} while (option != 4);
}
void menu()
{
cout << "System Menu" << endl;
cout << "1 - Withdraw" << endl;
cout << "2 - Deposit" << endl;
cout << "3 - Exit" << endl;
cout << "Select option: ";
}
BankAccount findaccount(int bankacnt_number, BankAccount acntaccount[], int listsize)
{
BankAccount account;
//account 1
BankAccount ac1("savings", "mario ling", 123, 0, 500.0);
//account 2
BankAccount ac2("savings", "orrin jones", 124, 1, 1000.0);
//account 3
BankAccount ac3("current", "Shean Peart", 125, 1, 1000.0);
//account 4
BankAccount ac4("current", "Lisa Hanna", 126, 0, 1000.0);
//account 5
BankAccount ac5("savings", "Leighton Ford", 127, 1, 500.0);
acntaccount[0] = ac1;
acntaccount[1] = ac2;
acntaccount[2] = ac3;
acntaccount[3] = ac4;
acntaccount[4] = ac5;
for (int idx = 0; idx < listsize; idx++)
{
if (acntaccount[idx].getAcntNumber() == bankacnt_number)
{
account = acntaccount[idx];
break;
}
}
return account;
}
//withdraw
BankAccount withdraw()
{
BankAccount ac;
string acnt_type;
string owners_name;
int acnt_number = 0;
bool status = 0;
double w_amount, bal;
if (ac.getStatus() == 0){
cout << "\nAccount status in Inactive Please Actvivate the account pressing 1:";
cin >> status;
}
else if (ac.getBalc()== 500.0)
{
cout << "savings account" << endl;
cout << "\nenter withdraw amount: ";
cin >> w_amount;
bal = 500;
bal = bal - w_amount;
cout << "\namount is withdraw successfully\n";
cout << "\nAvailable balance is:" << bal <<endl;
cout << "\n" << endl;
}
else if (ac.getBalc() == 1000.0)
cout << "current account" << endl;
cout << "\nenter withdraw amount: ";
cin >> w_amount;
bal = 1000;
bal = bal - w_amount;
cout << "\namount is withdraw successfully\n";
cout << "\nAvailable balance is:" << bal <<endl;
cout << "\n" << endl;
return BankAccount(acnt_type, owners_name, acnt_number, status, bal);
}
//Deposit
BankAccount deposit()
{
BankAccount ac;
string acnt_type;
string owners_name;
int acnt_number = 0;
bool status = 0;
double d_amount, bal;
if (ac.getStatus() == 0){
cout << "\nAccount status in Inactive Please Actvivate the account pressing 1:";
cin >> status;
}
else if (acnt_type == "savings")
{
cout << "savings account" << endl;
cout << "\nenter Deposit amount: ";
cin >> d_amount;
bal = 500;
bal = bal + d_amount;
cout << "\namount is Deposited successfully\n";
cout << "\nAvailable balance is:" << bal <<endl;
cout << "\n" << endl;
}
else
cout << "current account" << endl;
cout << "\nenter Deposit amount: ";
cin >> d_amount;
bal = 1000;
bal = bal + d_amount;
cout << "\namount is Deposited successfully\n";
cout << "\nAvailable balance is:" << bal <<endl;
cout << "\n" << endl;
return BankAccount(acnt_type, owners_name, acnt_number, status, bal);
}
| |