Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <limits>
- using namespace std;
- //Global Variables
- //Balance Variables
- float savingsBalance = 0;
- float creditBalance = 0;
- //Memory Variable
- bool exitBank = false;
- //Name String Variable
- string groupName = "Carl'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(){
- while (exitBank != true){
- string inputMenu = "inputMenu";
- 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
- // Exit
- tab_B2();
- cout << "[4] Exit";
- cout << endl;
- // Exit
- // Enter Input
- tab_B2();
- cout << "Enter Input: ";
- cin >> inputMenu;
- } while(!(inputMenu == "1" || inputMenu == "2" || inputMenu == "3" || inputMenu == "4")); // 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;
- 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;
- 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 = exitProgram();
- }
- } //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;
- }
- else if (memBalance == 1){
- balance = creditBalance;
- }
- 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){
- savingsBalance += 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 += inputBankAction;
- else if (actionBank2 == 1) creditBalance -= 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();
- 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