Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <limits>
- using namespace std;
- //Global Variables
- //PIN Arrays
- int PIN[] = { 1111, 2222, 3333, 4444 };
- int ID = -1;
- //Balance Variables
- float savingsBalance[] = { 100, 200, 300, 400 };
- float creditBalance[] = { 10, 20, 30, 40 };
- //Memory Variable
- bool exitBank = false;
- bool exitPIN = false;
- //Name String Variable
- string groupName = "Test's ";
- string currency = "Php ";
- //Prototype Functions
- //Menu Function
- //void menuBank(void);
- //Action Functions
- bool anotherBankTransaction(void);
- //Deposit Functions
- void actionBank(int memBalance, int actionBank2);
- //Savings or Credit Functions
- int s_c_Balance(int mem);
- //Exit Functions
- bool exitProgram(void);
- //Tab Functions
- void tab_B1(void);
- void tab_B2(void);
- void tab_B3(void);
- main(){
- int PIN2 = -1;
- bool exitPIN2 = false;
- bool validInputPIN = false;
- while (exitPIN != true){
- exitPIN = false;
- exitPIN2 = false;
- exitBank = false;
- ID = -1;
- do {
- // Welcome //
- tab_B1(); tab_B3();
- tab_B2();
- cout << "Welcome to " << groupName << " Bank!";
- tab_B1(); tab_B3();
- cout << endl;
- // Welcome //
- // Enter PIN //
- tab_B2();
- cout << "Enter PIN: ";
- cin >> PIN2;
- if (!(validInputPIN = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- // Enter PIN //
- for (int verify = 0; verify <= 3; verify++){
- if (PIN2 == PIN[verify]){
- ID = verify;
- exitPIN2 = true;
- }
- }
- } while (exitPIN2 != true);
- while (exitBank != true){
- string inputMenu = "null";
- int memBalance = -1; //0 - Savings Account, 1 - Credit Account
- int actionBank2 = -1; // 0 - Deposit, 1 - Withdraw
- do {
- // Welcome //
- tab_B1(); tab_B3();
- tab_B2();
- cout << "Welcome to " << groupName << " Bank!";
- tab_B1(); tab_B3();
- cout << endl;
- // Welcome //
- // Action Menu //
- // Check Balance
- tab_B2();
- cout << "[1] Check Balance";
- cout << endl;
- // Check Balance
- // Deposit
- tab_B2();
- cout << "[2] Deposit";
- cout << endl;
- // Deposit
- // Withdraw
- tab_B2();
- cout << "[3] Withdraw";
- cout << endl;
- // Withdraw
- // Logout
- tab_B2();
- cout << "[4] Log Out";
- cout << endl;
- // Logout
- // Exit
- tab_B2();
- cout << "[5] Exit";
- cout << endl;
- // Exit
- // Enter Input
- tab_B2();
- cout << "Enter Input: ";
- cin >> inputMenu;
- } while(!(inputMenu == "1" || inputMenu == "2" || inputMenu == "3" || inputMenu == "4" || inputMenu == "5")); // do while
- if (inputMenu == "1"){ // Check Balance
- do {
- //Check Balance Aesthetics
- tab_B1(); tab_B3();
- tab_B2();
- cout << groupName << " Bank: Check Balance";
- tab_B1(); tab_B3();
- cout << endl;
- //Check Balance Aesthetics
- //Savings or Credit Balance?
- memBalance = s_c_Balance(memBalance);
- } while (!(memBalance == 0 || memBalance == 1)); // Check Balance
- if (memBalance == 0){
- //Savings Balance
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << "Your savings balance: " << currency << savingsBalance[ID];
- cout << endl;
- system("pause");
- //Savings Balance
- exitBank = anotherBankTransaction();
- } //if
- if (memBalance == 1){
- //Credit Balance
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << "Your credit balance: " << currency << creditBalance[ID];
- cout << endl;
- system("pause");
- //Credit Balance
- exitBank = anotherBankTransaction();
- } //if
- } // Check Balance
- else if (inputMenu == "2"){ //Deposit
- actionBank2 = 0;
- actionBank(memBalance, actionBank2);
- } // Deposit
- else if (inputMenu == "3"){ //Withdraw
- actionBank2 = 1;
- actionBank(memBalance, actionBank2);
- }
- else if (inputMenu == "4"){
- exitBank = true;
- }
- else if (inputMenu == "5"){
- exitBank = exitProgram();
- exitPIN = true;
- }
- } //while loop
- }
- }
- //Action Function
- //Action Functions
- //Deposit Functions
- void actionBank(int memBalance, int actionBank2){
- //actionBank2 0 - Deposit, 1 - Withdraw
- bool validInput = false;
- string actionBankString[] = { "Deposit", "Withdraw" };
- string actionBankString2[] = { "deposit", "withdraw" };
- string actionBankString3[] = { " has been added to", " has been reduced from" };
- do {
- //Deposit/Withdraw Aesthetics
- tab_B1(); tab_B3();
- tab_B2();
- cout << groupName << " Bank: " << actionBankString[actionBank2];
- tab_B1(); tab_B3();
- cout << endl;
- //Deposit/Withdraw Aesthetics
- //Savings or Credit Account
- memBalance = s_c_Balance(memBalance);
- //Savings or Credit Account
- } while (!(memBalance == 0 || memBalance == 1));
- float inputBankAction = -1;
- //Ask Deposit/Withdraw
- tab_B1(); tab_B3();
- tab_B2();
- cout << "How much would you like to " << actionBankString2[actionBank2] << "?";
- tab_B1(); tab_B3();
- cout << endl;
- //Ask Deposit/Withdraw
- float balance = -1;
- if (memBalance == 0){
- balance = savingsBalance[ID];
- }
- else if (memBalance == 1){
- balance = creditBalance[ID];
- }
- if (actionBank2 == 0){
- do {
- //Enter Input
- tab_B2();
- cout << "Enter Amount: ";
- cin >> inputBankAction;
- if (!(validInput = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- //Enter Input
- } while (inputBankAction < 0);
- }
- else if (actionBank2 == 1){
- do {
- //Enter Input
- tab_B2();
- cout << "Enter Amount: ";
- cin >> inputBankAction;
- if (!(validInput = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- //Enter Input
- } while (inputBankAction < 0 || inputBankAction > balance);
- }
- //Deposit/Withdraw Output
- if (memBalance == 0){
- if (actionBank2 == 0) savingsBalance[ID] += inputBankAction;
- else if (actionBank2 == 1) savingsBalance[ID] -= inputBankAction;
- //Final Output
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << currency << inputBankAction << actionBankString3[actionBank2] << " your Savings Account.";
- cout << endl;
- //Final Output
- system("pause");
- }
- else if (memBalance == 1){
- if (actionBank2 == 0) creditBalance[ID] += inputBankAction;
- else if (actionBank2 == 1) creditBalance[ID] -= inputBankAction;
- //Final Output
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << currency << inputBankAction << actionBankString3[actionBank2] << " your Credit Account.";
- cout << endl;
- //Final Output
- system("pause");
- }
- exitBank = anotherBankTransaction();
- }
- //Savings or Credit Function
- int s_c_Balance(int mem){
- bool validInput = false;
- mem = -1;
- do {
- //Savings Account
- tab_B2();
- cout << "[1] Savings Account";
- cout << endl;
- //Savings Account
- //Credit Account
- tab_B2();
- cout << "[2] Credit Account";
- cout << endl;
- //Credit Account
- //Enter Input
- tab_B2();
- cout << "Enter Input: ";
- cin >> mem;
- if (!(validInput = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- //Enter Input
- } while (!(mem == 1 || mem == 2));
- return mem-1;
- }
- //Exit Functions
- bool anotherBankTransaction(void){
- int input;
- bool validInput = false;
- bool exitBankTransaction = false;
- do {
- //Ask Transaction
- tab_B2();
- cout << "Do you want another transaction? (1 - Yes/2 - No)";
- cout << endl;
- //Ask Transaction
- //Enter Input
- tab_B2();
- cout << "Enter Input: ";
- cin >> input;
- if (!(validInput = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- input--;
- //Enter Input
- } while (!(input == 0 || input == 1));
- if (input == 1){
- exitBankTransaction = exitProgram();
- exitPIN = true;
- return exitBankTransaction;
- }
- }
- bool exitProgram(void){
- cout << endl;
- cout << endl;
- tab_B2();
- cout << "Ending program . . . ";
- cout << endl;
- cout << endl;
- return true;
- }
- //Tabs Function
- void tab_B1(void){
- cout << endl;
- for (int a = 0; a <= 15; a++){
- cout << " ";
- }
- }
- void tab_B2(void){
- cout << endl;
- for (int a = 0; a <= 17; a++){
- cout << " ";
- }
- }
- void tab_B3(void){
- for (int a = 0; a <= 30; a++){
- cout << "=";
- }
- }
Add Comment
Please, Sign In to add comment