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
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string altpass = "altpass";
string command = "";
string option = "";
string check = "checkings";
string save = "savings";
string wthdl = "withdrawl";
string logout = "logout";
string depos = "deposit";
string cancel = "cancel";
string yes = "y";
string no = "n";
float chkaccntbal = 2000; //checkings, fix this later. only have it at 2000 for math testing purposes.
float svaccntbal = 2000; //savings, fix this later. only have it at 2000 for math testing purposes.
float withdrawl = 0;
float deposit = 0;
int sectic = 0; //security tics
cout << "Welcome to your account Mr. Johnson, \n" << endl;
cout << "You currently have $" << chkaccntbal << " in checkings." << endl;
cout << "You currently have $" << svaccntbal << " in savings. \n" << endl;
cout << "Do you wish to deposit, withdrawl, or logout?" << endl;
cin >> command;
//withdrawl
while (command == wthdl)
{
cout << "Would you like to withdrawl from checkings or savings?" << endl;
cin >> option;
if (option == check)
{
cout << "How much would you like to withdrawl from checking?" << endl;
cin >> withdrawl;
while (withdrawl > chkaccntbal)
{
cout << "Note: you are withdrawling more than what you have in your account." << endl;
cout << "Please enter a value less than or equal to $" << chkaccntbal << endl;
cin >> withdrawl;
}
if (withdrawl >= 1000)
{
cout << "Please enter your alternate password to complete the transaction." << endl;
cin >> altpass;
while (altpass != "altpass")
{
cout << "Incorrect alternate password, please try again." <<endl;
sectic = sectic + 1;
cin >> altpass;
if (sectic == 3)
{
cout << "Password inputed wrong too many times, ending system for security purposes" << endl;
cout << "Freezing account, please contact your local BoA to unfreeze account." << endl;
system ("pause");
return 0;
}
}
}
chkaccntbal = chkaccntbal - withdrawl;
cout << "You withdrew $" << withdrawl << " from checkings." << endl;
cout << "You currently have $" << chkaccntbal << " in checkings." << endl;
cout << "Do you wish to deposit, withdrawl, or logout?" << endl;
cin >> command;
}
if (option == save)
{
cout << "How much would you like to withdrawl from savings?" << endl;
cin >> withdrawl;
while (withdrawl > svaccntbal)
{
cout << "Note: you are withdrawling more than what you have in your account." << endl;
cout << "Please enter a value less than or equal to $" << svaccntbal << endl;
cin >> withdrawl;
}
if (withdrawl >= 1000)
{
cout << "Please enter your alternate password to complete the transaction." << endl;
cin >> altpass;
while (altpass != "altpass")
{
cout << "Incorrect alternate password, please try again." <<endl;
sectic = sectic + 1;
cin >> altpass;
if (sectic == 3)
{
cout << "Password inputed wrong too many times, ending system for security purposes" << endl;
cout << "Freezing account, please contact your local BoC to unfreeze account." << endl;
system ("pause");
return 0;
}
}
}
svaccntbal = svaccntbal - withdrawl;
cout << "You withdrew $" << withdrawl << " from savings." << endl;
cout << "You currently have $" << svaccntbal << " in savings." << endl;
cout << "Do you wish to deposit, withdrawl, or logout?" << endl;
cin >> command;
}
}
//deposit
while(command == depos)
{
cout << "Would you like to deposit into checkings or savings?" << endl;
cin >> option;
if (option == check)
{
cout << "How much would you like to deposit into checking?" << endl;
cin >> deposit;
chkaccntbal = chkaccntbal + deposit;
cout << "You deposited $" << deposit << " into checkings." << endl;
cout << "You currently have $" << chkaccntbal << " in checkings." << endl;
cout << "Do you wish to deposit, withdrawl, or logout?" << endl;
cin >> command;
}
if (option == save)
{
cout << "How much would you like to deposit into savings?" << endl;
cin >> deposit;
svaccntbal = svaccntbal + deposit;
cout << "You deposited $" << deposit << " into savings." << endl;
cout << "You currently have $" << svaccntbal << " in savings." << endl;
cout << "Do you wish to deposit, withdrawl, or logout?" << endl;
cin >> command;
}
}
//logout
if(command == logout)
{
cout << "Are you sure you want to logout? (y/n)" << endl;
cin >> option;
if (option == yes)
{
cout << "Logging out. Have a nice day." << endl;
system ("pause");
return 0;
}
if (option == no)
{
cout << "Do you wish to deposit, withdrawl, or logout?" << endl;
cin >> command;
}
}
while(command != depos || command != wthdl || command != logout)
{
cout << "Invalid command. Please try again." << endl;
cin >> command;
}
system ("pause");
return 0;
}
|