Advertisement
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
- int memBalance = -1; //0 - Savings Account, 1 - Credit Account
- //Name String Variable
- string groupName = "Test's ";
- string currency = "Php ";
- //Prototype Functions
- //Menu Function
- void menuBank(void);
- //Action Functions
- void anotherBankTransaction(void);
- //Deposit Functions
- void depositBank_A1(void);
- //Withdraw Functions
- void withdrawBank_A1(void);
- //Check Balance Functions
- void checkBalance_A1(void);
- //Savings or Credit Functions
- void s_c_Balance(void);
- //Exit Functions
- void exitProgram(void);
- //Tab Functions
- void tab_B1(void);
- void tab_B2(void);
- void tab_B3(void);
- main(){
- menuBank();
- }
- //Menu Function
- void menuBank(void){
- string input = "null";
- memBalance = -1;
- 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 >> input;
- } while(!(input == "1" || input == "2" || input == "3" || input == "4"));
- if (input == "1"){
- checkBalance_A1();
- }
- else if (input == "2"){
- depositBank_A1();
- }
- else if (input == "3"){
- withdrawBank_A1();
- }
- else if (input == "4"){
- exitProgram();
- }
- }
- //Action Function
- //Action Functions
- //Deposit Functions
- void depositBank_A1(void){
- string input = "null";
- bool validInput = false;
- do {
- //Deposit Aesthetics
- tab_B1(); tab_B3();
- tab_B2();
- cout << groupName << " Bank: Deposit";
- tab_B1(); tab_B3();
- cout << endl;
- //Deposit Aesthetics
- //Savings or Credit Account
- s_c_Balance();
- //Savings or Credit Account
- //Enter Input
- tab_B2();
- cout << "Enter Input: ";
- cin >> input;
- //Enter Input
- } while (!(input == "1" || input == "2"));
- //Balance Memory
- if (input == "1"){
- memBalance = 0; // Savings Account
- }
- else if (input == "2"){
- memBalance = 1; // Credit Account
- }
- //Balance Memory
- float depositInput = 0;
- do {
- //Ask Deposit
- tab_B1(); tab_B3();
- tab_B2();
- cout << "How much would you like to deposit?";
- tab_B1(); tab_B3();
- cout << endl;
- //Ask Deposit
- //Enter Input
- tab_B2();
- cout << "Enter Amount: ";
- cin >> depositInput;
- if (!(validInput = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- //Enter Input
- } while (depositInput < 0);
- //Deposit Output
- if (memBalance == 0){
- savingsBalance += depositInput;
- //Final Output
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << currency << depositInput << " has been added to your Savings Account.";
- cout << endl;
- //Final Output
- system("pause");
- }
- else if (memBalance == 1){
- creditBalance += depositInput;
- //Final Output
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << currency << depositInput << " has been added to your Credit Account.";
- cout << endl;
- //Final Output
- system("pause");
- }
- //Deposit Output
- anotherBankTransaction();
- }
- //Withdraw Functions
- void withdrawBank_A1(void){
- string input = "null";
- bool validInput = false;
- do {
- //Withdraw Aesthetics
- tab_B1(); tab_B3();
- tab_B2();
- cout << groupName << " Bank: Withdraw";
- tab_B1(); tab_B3();
- cout << endl;
- //Withdraw Aesthetics
- //Savings or Credit Account
- s_c_Balance();
- //Savings or Credit Account
- //Enter Input
- tab_B2();
- cout << "Enter Input: ";
- cin >> input;
- //Enter Input
- } while (!(input == "1" || input == "2"));
- //Balance Memory
- if (input == "1"){
- memBalance = 0; // Savings Account
- }
- else if (input == "2"){
- memBalance = 1; // Credit Account
- }
- //Balance Memory
- float withdrawInput = 0;
- if (memBalance == 0){
- do {
- //Ask Withdraw
- tab_B1(); tab_B3();
- tab_B2();
- cout << "How much would you like to withdraw?";
- tab_B1(); tab_B3();
- cout << endl;
- //Ask Withdraw
- //Enter Input
- tab_B2();
- cout << "Enter Amount: ";
- cin >> withdrawInput;
- //Enter Input
- if (!(validInput = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- } while (withdrawInput < 0 || withdrawInput > savingsBalance);
- }
- else if (memBalance == 1){
- do {
- //Ask Withdraw
- tab_B1(); tab_B3();
- tab_B2();
- cout << "How much would you like to withdraw?";
- tab_B1(); tab_B3();
- cout << endl;
- //Ask Withdraw
- //Enter Input
- tab_B2();
- cout << "Enter Amount: ";
- cin >> withdrawInput;
- //Enter Input
- if (!(validInput = cin.good())){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- } while (withdrawInput < 0 || withdrawInput > creditBalance);
- }
- //Withdraw Output
- if (memBalance == 0){
- savingsBalance -= withdrawInput;
- //Final Output
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << currency << withdrawInput << " has been reduced from your Savings Account.";
- cout << endl;
- //Final Output
- system("pause");
- }
- else if (memBalance == 1){
- creditBalance -= withdrawInput;
- //Final Output
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << currency << withdrawInput << " has been reduced from your Credit Account.";
- cout << endl;
- //Final Output
- system("pause");
- }
- //Withdraw Output
- anotherBankTransaction();
- }
- //Check Balance Functions
- void checkBalance_A1(void){
- string input;
- 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?
- s_c_Balance();
- //Enter Input
- tab_B2();
- cout << "Enter Input: ";
- cin >> input;
- //Enter Input
- } while (!(input == "1" || input == "2" || input == "3" || input == "4"));
- if (input == "1"){
- //Savings Balance
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << "Your savings balance: " << currency << savingsBalance;
- cout << endl;
- system("pause");
- //Savings Balance
- anotherBankTransaction();
- }
- if (input == "2"){
- //Credit Balance
- tab_B2();
- cout << setprecision(2) << fixed;
- cout << "Your credit balance: " << currency << creditBalance;
- cout << endl;
- system("pause");
- //Credit Balance
- anotherBankTransaction();
- }
- }
- //Savings or Credit Function
- void s_c_Balance(void){
- //Savings Account
- tab_B2();
- cout << "[1] Savings Account";
- cout << endl;
- //Savings Account
- //Credit Account
- tab_B2();
- cout << "[2] Credit Account";
- cout << endl;
- //Credit Account
- }
- //Exit Functions
- void anotherBankTransaction(void){
- string input;
- 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;
- //Enter Input
- } while (!(input == "1" || input == "2"));
- if (input == "1"){
- menuBank();
- }
- else if (input == "2"){
- exitProgram();
- }
- }
- void exitProgram(void){
- cout << endl;
- cout << endl;
- tab_B2();
- cout << "Ending program . . . ";
- cout << endl;
- cout << endl;
- abort();
- }
- //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 << "=";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement