Skip to content

Instantly share code, notes, and snippets.

@brand-it
Created June 7, 2012 16:20
Show Gist options
  • Save brand-it/2889838 to your computer and use it in GitHub Desktop.
Save brand-it/2889838 to your computer and use it in GitHub Desktop.
Banking application with a menu
#include "MenuHeader.h"
class Menu {
public:
void balanceStatment();
void options();
void bankInfo();
void accountInfo();
void statements();
void selection();
void askWithdraw();
void askDeposit();
void render();
};
void Menu::balanceStatment(){
cout << "Your current balance is: $" << balance << endl;
};
void Menu::options(){
cout << "1. Check balance" << endl;
cout << "2. Make withdrawal" << endl;
cout << "3. Make deposit" << endl;
cout << "4. View account information" << endl;
cout << "5. View statement" << endl;
cout << "6. View bank information" << endl;
cout << "7. Exit" << endl;
};
void Menu::bankInfo(){
cout << "Devry Bank, established 2011" << endl;
cout << "(123) 456-7890" << endl;
cout << "12345 1st St." << endl;
cout << "Someplace, NJ 12345" << endl;
}
void Menu::accountInfo(){
cout << "Brandt Lareau" << endl;
cout << "Account number: 8324929" << endl;
}
void Menu::statements(){
cout << "01/01/11 - McDonald’s - $6.27" << endl;
cout << "01/15/11 - Kwik Trip - $34.93" << endl;
cout << "02/28/11 - Target - $124.21" << endl;
}
void Menu::selection(){
int input;
cout << "Use Keys 1 - 7 to make selection: ";
cin >> input;
if(input < 8 && input >= 0){
menu_selection = input;
} else {
cout << "Sorry you selection was not found please select from the menu below" << endl;
options();
selection();
}
}
void Menu::askWithdraw(){
float withdraw = 0;
cout << "How much would you like to withdraw? $";
cin >> withdraw;
balance = balance - withdraw;
}
void Menu::askDeposit(){
float deposit;
cout << "How much would you like to deposit? $";
cin >> deposit;
balance = deposit + balance;
}
void Menu::render(){
if(menu_selection == 1){
balanceStatment();
} else if (menu_selection == 2){
askWithdraw();
} else if (menu_selection == 3){
askDeposit();
} else if (menu_selection == 4){
accountInfo();
} else if (menu_selection == 5){
statements();
} else if (menu_selection == 6){
bankInfo();
} else if (menu_selection == 7){
running = false;
} else {
selection();
}
}
void main(){
Menu menu;
while(running){
menu.options();
menu.selection();
menu.render();
}
system("pause");
}
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
float balance;
int menu_selection = 0;
bool running = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment