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
|
#include <iostream>
using namespace std;
enum transType
{
SETUP = 1,
DEPOSITE,
WITHDRAW,
EXIT
};
bool quit = 0;
int showMenu(int menuSwitch, int amount, double balance);
double transaction(double amount, double balance, transType trans);
int main()
{
int menuSwitch, amount = 0;
double balance = 0.0;
while(!quit)
{
showMenu(menuSwitch, balance, amount);
}
return 0;
}
int showMenu(int menuSwitch, int amount, double balance){
cout<<"Your Online Checking Account System"<<endl;
cout<<"-------------------------------------------"<<endl;
cout<<"Select an option:"<<endl<<endl;
cout<<" 1. Set up the account."<<endl;
cout<<" 2. Deposit Funds into your Account."<<endl;
cout<<" 3. Withdraw Funds out of your Account."<<endl;
cout<<" 4. Exit"<<endl;
cout<<endl<<">>";
cin>>menuSwitch;
switch (menuSwitch){
case SETUP:
cout<<"Enter the balance: ";
cin>>balance;
cout<<endl<<"Your current balance is: "<<balance<<endl<<endl;
break;
case DEPOSITE:
cout<<"Enter the amount of deposit: ";
cin>>amount;
cout<<"Your current balance is: "<<transaction(amount,balance,DEPOSITE)<<endl<<endl;
break;
case WITHDRAW:
cout<<"Enter the amount of withdraw: ";
cin>>amount;
if(amount>balance){
cout<<"*** Insufficient funds."<<"Your current balance is: "<<transaction(amount,balance,WITHDRAW)<<endl<<endl;
}
else cout<<"Your current balance is: "<<transaction(amount,balance,WITHDRAW)<<endl<<endl;
break;
case EXIT:
cout<<"Have a Nice Day."<<endl;
quit=true;
break;
default:
cout << "Invalid choice! Please, try again. \n";
break;
}
}
double transaction(double amount, double balance, transType trans){
double withdraw = balance-amount;
double deposite = balance+amount;
if(trans==DEPOSITE){
return deposite;
}
else
return withdraw;
}
//return balance;
|