helppp in bank databse

This is a discussion on helppp in bank databse within the C++ Programming forums, part of the General Programming Boards category; any one of u plz help me in my code actually my project is about bank database in oop .in ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    35

    helppp in bank databse

    any one of u plz help me in my code actually my project is about bank database in oop .in this bank two accounts saving and current . in saving account their is interest but in current it is nt .the problem is that when i run the program and call current account and deposit or withdraw money the out put from which i m xpecting. means it take input but not show calculated money in current account.but if i call interest function in deposit and withdraw of current it properly works other wise nt .plz tell me where i m wrong.its urgent plzzzzzzzzz coz i have to submit it on monday
    Code:
    #include<iostream.h>
    #include<conio.h>
    #include<string.h>
    #include<stdlib.h>
    #include<math.h>
    #include<stdio.h>
    
    const double interest=0.03;
    const double Natural_E=2.712;
    int acc_no[100];
    static int a;
    class bank{
    	protected  :
    		  char name[20],op;
    		  int arr;
    	protected:	  double balance;
    		  double original;
    		  double deposit_money;
    		  double withdraw_money;
    		  int years,t;
    		  int n;
    public:	   bank(){
    		  name[0]='\0';
    		  balance=0;
    		  original=0;
    		  deposit_money=0;
    		  withdraw_money=0;
    		  years=0;
    		  a=0;
    		  };
    
    	   void instructions(){
    		       cout<<"\n\t\t\t* ======================= *\n"
    			     "\t\t\t*  Well come to           *\n"
    			     "\t\t\t*           MFB           *\n"
    			     "\t\t\t* ======================= *\n\n";
    		       cout<<"\t\tThis bank will give you facility to open current\n"
    			     "\t\t\t as well as saving account\n\n";
    		       cout<<"\t\t\t   To proceed press enter";
    		       getch();
    		       };
    	   void input_balance(){
    		       cout<<"\t\tEnter the current balance on your account in PK.RS:";
    		       cin>>balance;
    		       original=balance;
    		       };
    
    	   void create(){
    		       cout<<"\t\t\t     Enter your NAME:";
    		       cin>>name;
    		       cout<<"\n\t\t\t  **** Congratulation****\n";
    		       cout<<"\t\t\t  You become a part of MFB\n";
    		     if(a<100)
    		     a++;
    		     else
    		     {
    		     cout<<"Account number exceeds its limit!"<<endl;
    		     getch();
    		     return;
    		     }
    		     acc_no[a-1]=a;
    		      cout<<"\t\t       your personal informations are\n\n";
    		       cout<<"\t\t\t      Your NAME is:"<<name<<endl;
    		       cout<<"\t\t\t    Your ACCOUNT no is:"<<a<<endl<<endl;
    		       };
    	   void deposit()
    		       {
    		       cout<<"\n\n\t\t\tWell come in your account:"<<name<<endl;
    		       cout<<"\t\t\tHow much do you want to deposit:RS ";
    		       cin>>deposit_money;
    		       balance+=deposit_money;
    		       cout<<"\t\t\tYour new balance after DEPOSIT is:RS "<<balance;
    
    		       };
    	   void withdraw()
    		       {
    			cout<<"\n\n\t\t\tWell come in your account:"<<name<<endl;
    		       cout<<"\t\t\tHow much do you want to withdraw:RS ";
    		       cin>>withdraw_money;
    		       balance-=withdraw_money;
    		       if(balance>0)
    		       cout<<"\t\t\tYour new balance after WITHDRAW is:RS "<<balance;
    		       else
    		       cout<<"\t\t\tZERO balance in your account";
    		       };
    	   double interestpay(int years)
    		  {
    		       double temp,temp2;
    
    		       temp=interest*years;
    		       temp2=pow(Natural_E,temp);
    
    		       return balance*temp2;
    		  };
    	   void numyears()
    		     {
    		     cout<<"\t\tHow many years have passed since the last transaction \n\t\t\t\tor starting this account: ";
    		     cin>>years;
    		     balance=interestpay(years);
    		     cout<<"\n\n\t\t\tThe new balance after transction is:"<<balance;
    		     getch();
    		     }
    };
    //int bank::acc_no=0;
         class saving:public bank
         {
           public:
    	  void create_s(){
    		     clrscr();
    		     cout<<"\n\t\t\t* ======================= *\n"
    			   "\t\t\t*  Well come to           *\n"
    			   "\t\t\t*     MFB saving account  *\n"
    			   "\t\t\t* ======================= *\n";
    		     cout<<"\t\t\t  This account gives you \n\t\tAn interest rate of";
    		     cout<<interest*100<<"% compounded continuously\n\n";
    		     bank::create();
    		    cout<<"\t      DO you want to enter money into your account [Y/N]:";
    		    cin>>op;
    		    if(op=='y')
    		    bank::input_balance();
    		     };
    	  void swithdraw(){
    		       cout<<"\t\t    Enter your Account No to deposit:";
    		       cin>>arr;
    		       int flag=0;
    		       for(int i=0; i<a; i++)
    		       {
    			       if(arr==acc_no[i])
    			       {
    			       flag=1;
    			       bank::withdraw();
    				cout<<"\n\n\t\tDo you want to check interest added into your account [Y/N]: ";
    				cin>>op;
    
    				if(op=='y')
    			      numyears();
    			       }
    		       }
    		       if(flag==0)
    		       cout<<"\n\t\tAccount doesn't exist!!\n\n";
    
    
    
    		       };
    
    	  void sdeposit(){
    		     cout<<"Enter your Account No to deposit:";
    		     cin>>arr;
    		  //    t= arr-acc_no;
    			int flag=0;
    		       for(int i=0; i<a; i++)
    		       {
    				if(arr==acc_no[i])
    			       {      flag=1;
    				      bank::deposit();
    				       cout<<"\n\nDo you want to check interest added into your account [Y/N]:";
    					cin>>op;
    				       if(op=='y')
    					      numyears();
    						 }
    			       //else
    				//
    		       }
    		       if(flag==0)
    		       cout<<"\nAccount doesn't exist!!\n\n";
    		};
           };
    
         class current_acc:public bank
           {
    
           public:
    	  void create_c(){
    	  clrscr();
    		     cout<<"\n\t\t\t* ======================= *\n"
    			   "\t\t\t*  Well come to           *\n"
    			   "\t\t\t*     MFB current account *\n"
    			   "\t\t\t* ======================= *\n";
    		     cout<<"\n\t\t   This account is for business peoples \n\t\t   Their is no interest in this account\n\n";
    		     bank::create();
    		      cout<<"\t      DO you want to enter money into your account [Y/N]:";
    		    cin>>op;
    		    if(op=='y')
    		    bank::input_balance();
    		     };
    	  void cdeposit(){
    		   cout<<"\t\t    Enter your Account No to deposit:";
    		     cin>>arr;
    		       int flag=0;
    		       for(int i=0; i<a; i++)
    		       {
    			       if(arr==acc_no[i])
    			       {
    			       flag=1;
    
    				 bank::deposit();
    				 cout<<"congratz";
    				    /*   cout<<"\n\nDo you want to check interest added into your account [Y/N]:";
    					cin>>op;
    				       if(op=='y')
    					      numyears(); */
    
    			       }
    		       }
    		       if(flag==0)
    		       cout<<"\n\t\tAccount doesn't exist!!\n\n";
    	};
    
    
    	  void cwithdraw(){
    		   cout<<"\t\t    Enter your Account No to deposit:";
    		     cin>>arr;
    		       int flag=0;
    		       for(int i=0; i<a; i++)
    		       {
    			       if(arr==acc_no[i])
    			       {
    			       flag=1;
    				  bank::withdraw();
    				  /*     cout<<"\n\nDo you want to check interest added into your account [Y/N]:";
    					cin>>op;
    				       if(op=='y')
    					     numyears();  */
    			       }
    		       }
    		       if(flag==0)
    		       cout<<"\n\t\tAccount doesn't exist!!\n\n";
    			  };
           };
    
    main()
    {
    clrscr();
    int z;
    saving s;
    current_acc c;
    char op,nm[20],str[20];;
    bank b1[100],b2;
    b2.instructions();
    
    for(int i=0;i<100;)
           {     clrscr();
    	     cout<<"\n\t\t\t1.   Press c to CREATE ACCOUNT\n"
    		   "\t\t\t2.   Press d to DEPOSIT\n"
    		   "\t\t\t3.   w to WITHDRAW\n"
    		    "\t\t\t4.   q to QUIT\n";
    	     cin>>op;
           switch(op)
    	      {
    		case'c':
    		clrscr();
    		    cout<<"\n\n\tyou pressed c\n";
    		    cout<<"\tWhich account do u want to create\n";
    		    cout<<"\tCurrent or saving\n";
    		    cout<<"\tTo create saving account press 'saving'\n"
    			  "\tTo create current press 'current':";
    		    gets(str);
    		    int m=strcmp(str,"current");
    		    if(m==0)
    			c.create_c();
    		    else
    			 s.create_s();
    		    break;
    		case'd':
    		    clrscr();
    		    cout<<"\t\t  In which account do you want to deposit:";
    		    gets(str);
    		    m=strcmp(str,"current");
    
    			if(m==0)
    			c.cdeposit();
    			else
    			s.sdeposit();
    		    break;
    		case'w':
    		    cout<<"\tFrom which account do you want to withdraw:";
    		    gets(str);
    		    m=strcmp(str,"current");
    
    			if(m==0)
    			  c.cwithdraw();
    			else
    			  s.swithdraw();
    		    break;
    
    		case'q':
    		    cout<<"\n\tyou pressed q";
    		    if(op=='q')
    		    {
    		    exit(0);
    		    }
    		    break;
    		default:
    		    cout<<"unknown";
    	      }
           i++;
           }
    getch();
    }

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    why do you use C-strings and gets function (that is HIGHLY NOT recommended even in C)?

    You should start using modern C++ technics
    std::string, std::vector

    iostream.h is outdated
    etc
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bank Account Problem
    By JayBlay77 in forum C++ Programming
    Replies: 1
    Last Post: 03-19-2009, 08:41 AM
  2. Replies: 12
    Last Post: 06-03-2005, 01:13 AM
  3. Bank Account
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 09-14-2003, 02:27 AM
  4. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21