1 Replies - 2682 Views - Last Post: 04 November 2008 - 11:48 PM Rate Topic: -----

#1 kausy1234  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-November 08

Online Banking.

Posted 04 November 2008 - 07:19 AM

This is my current code for Online baking, which I made myself. However, i am not able to add more features. I want to add features like : being able to handle(debit and
credit) three or more accounts. Also, the account numbers and the money present should be user defined. Can anyone please add these two features and help me out. :)

 #include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>

int cb=5000,fb=3000,sb=2000,amt,from,to;
void bal();
void trans();
void store(int);

void main()
{
void menu();

clrscr();
fstream file;

file.open("cust",ios::out);

file<<"\t\t\tWELCOME DEAR CUSTOMER"<<endl;
file<<"****************************************************************************"<<endl;
file<<" Your account numbers are:"<<endl;
file<<"\n Fixed:101"<<endl<<"current:102"<<endl<<"savings:103"<<endl;
file<<"--------------------------------------------------------"<<endl;


file.close();

const int N=1000;
char line[N];

file.open("cust",ios::in);

while(file.eof()==0)
{
file.getline(line,N);
cout<<line;
}
getch();
file.close();
clrscr();
menu();
}

void menu()
{
cout<<"\n press 1 to transact and 2 to check your balance and 3 to exit!! ";
int x;
cin>>x;
if(x==1)
trans();
else if(x==2)
bal();
else if(x==3)
exit(1);
}

void trans()
{

fstream file;

file.open("cust",ios::app);

cout<<endl<<"enter the account from which you want to transfer amount";
cin>>from;
cout<<endl<<"enter the account to which you want to transfer";
cin>>to;
cout<<endl<<"enter the amount to be transacted";
cin>>amt;

if(from==101 && to==102)
{
if(amt<=cb)
{
cb=cb-amt;
fb=fb+amt;
const int x=cb;
store(x);
}
else
{
cout<<"LOW BALANCE"<<endl;
menu();
}
}
else if(from==101 && to==103)
{
if(amt<=cb)
{
cb=cb-amt;
sb=sb+amt;
}
else
{
cout<<"LOW BALANCE"<<endl;
menu();
}
}
else if(from==102 && to==101)
{
if(amt<=fb)
{
fb=fb-amt;
cb=cb+amt;
}
else
{
cout<<"LOW BALANCE"<<endl;
menu();
}
}
else if(from==102 && to==103)
{
if(amt<=fb)
{
fb=fb-amt;
sb=sb+amt;
}
else
{
cout<<"LOW BALANCE"<<endl;
menu();
}
}
else if(from==103 && to==101)
{
if(amt<=sb)
{
sb=sb-amt;
cb=cb+amt;
}
else
{
cout<<"LOW BALANCE"<<endl;
menu();
}
}
else if(from==103 && to==102)
{
if(amt<=sb)
{
sb=sb-amt;
fb=fb+amt;
}
else
{
cout<<"LOW BALANCE"<<endl;
menu();
}
}
else
{
cout<<endl<<"please check your account numbers.....press enter";
getch();
clrscr();
menu();
}

cout<<"\n The transaction has been done succesfully";
cout<<"\n--------------------------------------------------------";
cout<<endl<<"\n\n  YOUR BALANCE IN RESPECTIVE ACCOUNTS:";
file<<endl<<"current:"<<cb<<endl;
file<<"fixed:"<<fb<<endl;
file<<"savings:"<<sb<<endl;


file.close();
getch();
clrscr();

const int N=100;
char lin[N];

file.open("cust",ios::in);

while(file)
{
file.getline(lin,N);
cout<<lin;
}
file.close();

getch();
clrscr();
cout<<endl<<"\t\t\tTHANK YOU FOR VISITING"<<endl<<"\t\t\n\n\n\npress 1 to quit";
int y;
cin>>y;
if(y==1)
exit(1);
}

void bal()
{
cout<<endl;
cout<<" BALANCE IN:";
cout<<"\n current : "<<cb;
cout<<"\n fixed :"<<fb;
cout<<"\n savings :"<<sb;
getch();
}

void store(int x)
{
cout<<"current:"<<x;
getch();
}



Is This A Good Question/Topic? 0
  • +

Replies To: Online Banking.

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4354
  • View blog
  • Posts: 12,160
  • Joined: 18-April 07

Re: Online Banking.

Posted 04 November 2008 - 11:48 PM

This is the perfect situation where you should be creating a class called "Account". An account has the ability to hold the balance, add credits and debits, and can be used to handle multiple accounts and even multiple types of accounts (like savings, checking etc).

I would suggest you do a little research on creating classes and create a simple account class. Once you have that put in place, we can show you how to use the class in such a way that you can juggle around account classes and do all kinds of nifty things with them.

:)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1