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
|
//ATM.cpp
#include "ATMfinal.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
//bool exitProgram = false;
string bankName = "Livecchi National Credit Union";
bool exitProgram = false;
//initialize
bankAccount::bankAccount(string Name)
{
bankBalance = 1000;
setBankersName(Name);
}
//sets account name
void bankAccount::setBankersName(string name)
{
accountName = name;
}
//get name
string bankAccount::getBankName()
{
return accountName;
}
//set balance
double bankAccount::getBankBalance()
{
return bankBalance;
}
void bankAccount::displayBalance()
{
system("cls");
cout << "Viewing account balance for account: \"" << getBankName() << "\"" << endl << endl;
cout << endl << accountName << endl;
for (int i = 0; i < 40; i++)
cout << "~";
cout << endl << fixed << "Bank Account Balance is: $" << setprecision(2) << bankBalance << endl << endl;
cout << endl;
system("PAUSE");
}
//transfer $
void bankAccount::transMoney2(bankAccount &bankAccount, double amount)
{
bankBalance -= amount;
cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << endl << endl;
cout << fixed << setprecision(2) << bankAccount.getBankName() << "Balance: $" << bankAccount.
getBankBalance() << bankBalance << endl << endl;
system("PAUSE");
}
void bankAccount::depositMoney(double amount)
{
bankBalance += amount;
cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
system("PAUSE");
}
void bankAccount::withdrawlMoney(double amount)
{
bankBalance -= amount;
cout << endl << fixed << setprecision(2) << accountName << "Balance is now: $" << bankBalance << endl << endl;
system("PAUSE");
}
void showBankMenu(bankAccount &account)
{
int selected = 0;
double amount;
system("CLS");
cout << "Manage a " << ::bankName << " account: \"" << account.getBankName() << "\"" << endl << endl;
cout << endl;
cout << "1- View Bank Account Balance" << endl;
cout << "2- Deposit money to this Account" << endl;
cout << "3- Withdrawl money from this Account" << endl;
cout << "4- *Return to Main Menu*" << bankName << " Account" << endl;
cout << "Enter Choice: " << endl;
cin >> selected;
switch (selected)
{
case 1:
account.displayBalance();
break;
case 2:
cout << endl << "Enter deposit amount: $";
cin >> amount;
transCheck(account, amount, false);
account.depositMoney(amount);
break;
case 3:
cout << endl << "Enter withdrawl amount: ($" << account.getBankBalance() << " available): $";
cin >> amount;
transCheck(account, amount, true);
account.withdrawlMoney(amount);
break;
case 4:
break;
default:
cout << endl << "Invalid Entry please try again" << endl << endl;
system("PAUSE");
break;
}
}
void manageBankAccounts(bankAccount &checking, bankAccount &savings)
{
int selection = 0;
// system("cls");
cout << "Welcome to Livecchi National Credit Untion" << endl;
cout << endl;
cout << "1- Manage Savings account" << endl;
cout << "2- Manage Checking account" << endl;
cout << "3- Transfer Money" << endl;
cout << "4- Exit " << savings.getBankName() << endl << endl;
cout << "Enter Selection: ";
cin >> selection;
switch (selection)
{
case 1:
showBankMenu(savings);
break;
case 2:
showBankMenu(checking);
break;
case 3:
transMenu(checking, savings);
break;
case 4:
::exitProgram = true;
break;
default:
cout << endl << "Invalid entry please try again" << endl << endl;
system("PAUSE");
break;
}
}
void transMenu(bankAccount &account1, bankAccount& account2)
{
int selection;
double transAmount = 0.00;
system("CLS");
cout << "Transfer money between account: " << account1.getBankName() << endl << endl;
cout << endl;
cout << "1- Transfer from \"" << account1.getBankName() << " to " << account2.getBankName() << "\"" << endl;
cout << "2- Transfer from \"" << account2.getBankName() << " to " << account1.getBankName() << "\"" << endl;
cout << "3- Back to Main Menu" << endl;
cout << endl << "Enter Selection: ";
cin >> selection;
switch (selection)
{
case 1:
cout << endl << "Enter amount of transfer ($" << account1.getBankBalance() << " available): $";
cin >> transAmount;
transCheck(account1, transAmount, true);
account1.transMoney2(account2, transAmount);
break;
case 2:
cout << endl << "Enter amount of transfer ($" << account2.getBankBalance() << " available): $";
cin >> transAmount;
transCheck(account2, transAmount, true);
account2.transMoney2(account1, transAmount);
break;
case 3:
break;
default:
cout << endl << "Invalid entry please try again" << endl << endl;
system("PAUSE");
break;
}
}
void transCheck(bankAccount& acct, double &amount, bool checkOverdrawl)
{
if (fmod((amount * 100), 1) != 0.00)
{
cout << endl << "This entry is invalid. Cancelling..." << endl;
amount = 0;
}
else if (amount < 0)
{
cout << endl << "Cannot transfer a Negative amount." << endl;
amount = 0;
}
else
{
cout << endl << " Transaction Processing " << endl;
}
}
bool getProgStat()
{
return ::exitProgram;
}
|