#include "stdafx.h"
#include <iostream.h>
#include <conio.h>
#include <windows.h>
struct accounts{
int acnum1;
int acnum2;
int acnum3;
double balance1;
double balance2;
double balance3;
};
typedef struct accounts account;
account init (account);
account deposit (account);
account withdraw (account);
void query (account);
void showall (account);
int main(int argc, char* argv[])
{
account bank;
bank = init (bank);
char transaction;
while (transaction != 'E'){
cout<<"\n++++++++++\n";
cout<<"WORLD BANK\n";
cout<<"\n++++++++++\n\n";
cout<<"deposit -----> <press> D\n";
cout<<"withdraw -----> <press> W\n";
cout<<"Query -----> <press> Q\n";
cout<<"Show All -----> <press> S\n";
cout<<"Exit -----> <press> E\n";
cout<<"\n\n";
cout<<"please select your transaction :";
cin>>transaction;
switch(transaction){
case 'D':
bank = deposit(bank);
break;
case 'W':
bank = withdraw(bank);
break;
case 'Q':
query(bank);
break;
case 'S':
showall(bank);
break;
case 'E' || 'e':
exit(0);
break;
default:
"please select one of the items from the menu item";
break;
}
system("CLS");
}
return 0;
}
account init (account buffer){
buffer.acnum1 = 11111;
buffer.acnum2 = 22222;
buffer.acnum3 = 33333;
buffer.balance1 = 0;
buffer.balance2 = 0;
buffer.balance3 = 0;
return buffer;
}
account deposit (account bank){
int ac_num;
double balance,deposit_amt;
cout<<"\nenter account number";
cin>>ac_num;
switch(ac_num){
case 11111:
cout<< "enter deposit amount ";
cin>>deposit_amt;
bank.balance1 = bank.balance1 + deposit_amt;
balance = bank.balance1;
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<balance;
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
case 22222:
cout<< "enter deposit amount ";
cin>>deposit_amt;
bank.balance2 = deposit_amt + bank.balance2;
balance = bank.balance2;
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<balance;
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
case 33333:
cout<< "enter deposit amount ";
cin>>deposit_amt;
bank.balance3 = deposit_amt + bank.balance3;
balance = bank.balance3;
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<balance<<".00";
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
default:
cout<<"acount number does not exist";
break;
}
return bank;
}
account withdraw (account bank){
int ac_num;
double balance,withdrawl_amt;
cout<<"\nenter account number";
cin>>ac_num;
switch(ac_num){
case 11111:
cout<< "enter withdrawl amount ";
cin>>withdrawl_amt;
bank.balance1 = bank.balance1 - withdrawl_amt;
balance = bank.balance1;
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<balance;
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
case 22222:
cout<< "enter withdrawl amount ";
cin>>withdrawl_amt;
bank.balance2 = bank.balance2 - withdrawl_amt;
balance = bank.balance2;
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<balance;
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
case 33333:
cout<< "enter withdrawl amount ";
cin>>withdrawl_amt;
bank.balance3 = bank.balance3 - withdrawl_amt;
balance = bank.balance3;
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<balance<<".00";
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
default:
cout<<"acount number does not exist";
break;
}
return bank;
}
void query (account bank){
int ac_num;
cout<<"\nenter account number";
cin>>ac_num;
switch(ac_num){
case 11111:
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<bank.balance1;
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
case 22222:
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<bank.balance2;
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
case 33333:
system("CLS");
cout<<"TRANSACTION APPROVED";
cout<<"\n++++++++++++++++++++++\n\n\n\n";
cout<<"Balance on your account :\n"<<"#"<<ac_num<<" is $"<<bank.balance3<<".00";
cout<<"\n\n\npresss ne button to continue";
cout<<endl;
getch();
break;
default:
cout<<"acount number does not exist";
break;
}
}
void showall (account bank){
system("CLS");
cout<<"DISPLAYING ALL EXISTING ACCOUNTS";
cout<<"\n++++++++++++++++++++++++++++++\n";
cout<<"ACCOUNT\t\t\t\tBALANCE\n\n\n";
cout<<"-------\t\t\t\t-------\n";
cout<<bank.acnum1<<"\t\t\t\t"<<bank.balance1<<"\n";
cout<<bank.acnum2<<"\t\t\t\t"<<bank.balance2<<"\n";
cout<<bank.acnum3<<"\t\t\t\t"<<bank.balance3<<"\n";
cout<<"\n\n\npress ne key to continue";
cout<<endl;
getch();
}