Bank project example using c++
#include
#include"fstream.h"
using std::cout;
using std::cin;
class BankUser{
public:
BankUser();
void viewBalance();
void deposit();
void withdraw();
double transfer1();
void transfer2(double);
private:
double blance;
};
BankUser::BankUser()
{
char type;
cout<<"enter the type for this Account";
cout<<"\n\ncheck Account :C";
cout<<"\nSaving Account :S";
cout<<"\n\n\ Enter ur Choice :";
cin>>type;
if (type=='S'||type=='S')
blance=1500;
else
blance=1000;
}
void BankUser::viewBalance()
{
cout<<"\n The Current Blane Of This Account Is="<>amount;
blance+=amount;
if(blance>2000)
blance+=50;
viewBalance();
}
void BankUser::withdraw()
{
double amount;
cout<<"Enter the Amount to be with drawn :";
cin>>amount;
blance-=amount;
if(blance<500)
blance-=25;
viewBalance();
}
double BankUser::transfer1()
{
double amount;
cout<<"Enetr The Amount to be Transfered";
cin>>amount;
}
void BankUser::transfer2(double amount)
{
blance+=amount;
}
void welcome()
{
cout<<"\n\n\t\t\t ABC Bank";
cout<<"\n\n\t\t\t ABC State";
char menu()
{
char choice;
cout<<"\n\n\t View Blance : V";
cout<<"\n\t\tDopist :D";
cout<<"\n\t\t Withdraw :W";
cout<<"\n\t\t Transfer :T";
cout<<"\n\t\t EXIT :E";
cout<<"\n\t Enter THE Choise :";
cin>>choice;
if(choice<92)
choice+=32;
return choice;
}
//MAIN MENU.........
int main()
{
welcome();
BankUser bu[5];
char ch;
int accNo;
do
{
ch=menu();
if(ch=='E')
break;
double tamount;
cout<<"\n\t Enter the Account Number(1..5) : ";
cin>>accNo;
switch(ch)
{
case 'V':bu[accNo -1].viewBalance();
break;
case 'D':bu[accNo -1].deposit();
break;
case 'W':bu[accNo -1].withdraw();
break;
case 'T':tamount=bu[accNo -1].transfer1();
cout<<"\n\t Enter the amount Number to be transfered : ";
cin>>accNo;
bu[accNo -1].transfer2(tamount);
break;
default :cout<<"\n\t Enter invalid menu option";
cout<<"\n\t Enter the valid Option.";
}
}
while (ch !='E');
cout<<"\n\t\t";
system("pause");
return 0;
}
//When the user creates an account, save his personal in formation
//in the file using a structure as follows:-
struct uerdata
{
char name[100];
char addr[100];
char phnum[12];
char accountnum[25];
// add more
};
struct userdata ud;
//then save this data in the binary format as follows:-
FILE *fs;
fs=fopen("usredata.dat","rb+");
if(fs==NULL)
{
fs=fopen("userdata.dat,"wb+");
if(fs==NULL)
{
// report error
}
}
fseek(fs,0L,SEEK_END);
fwrite(ud,sizeof(ud),1,fs);
//to read the userdata,
fs=fopen("userdata","rb+");
if(fs==NULL)
{
// report error
}