GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Feb-2008, 11:12
muhiuddin muhiuddin is offline
New Member
 
Join Date: Feb 2008
Posts: 4
muhiuddin is on a distinguished road
Exclamation

Need Assistance in C++


I have write the following code. Now I want help to update File. If user enters Withdrawal then the amount should be deducted and balance should be replaced in file or if user enter Deposit than after adding the deposit amount in balance the net balance should be updated. the Data text File is as below

Data.txt

Code:
01 abc 15000 02 aaa 20000 03 1ab 500 04 xyz 12500 05 s25 25000


CPP / C++ / C Code:
#include <iostream.h>
#include <stdlib.h>
#include <string>
#include <fstream>

class openAccount
{
      protected:
              string AcNo;
              string pass;
              int oBalance;
      public:
              openAccount()
              {
                  cout<<"Enter Account No. ";
                  cin>>AcNo;
                  cout<<"Enter Pasword";
                  cin>>pass;
                  cout<<"Enter Op Balance";
                  cin>>oBalance;
                  ofstream ab("Data.txt",ios::app);
                  if(!ab)
                  cout<<"Error!\n\n Your Account Cannot be Opened at this Time\n";
                  ab<<AcNo<<'\t'<<pass<<'\t'<<oBalance<<endl;
                  cout<<"Your Account Has Been Created Successfully\n";
              }
              ~openAccount(){}
};

class Account
{
      public:
             string ID;
             string pass;
             int Balance;
};



void transaction()
{
      int d;
      string a,b,c;
      Account au;

      cout<<"Enter Account No. ";
      cin>>a;
      cout<<"Enter Pasword";
      cin>>c;
      cout<<"Enter Transaction Type";
      cin>>b;
      cout<<"Enter Amount";
      cin>>d;

      cout<<"\n\nProcessing . . . . ";

      ifstream readFile("Data.txt",ios::in|ios::out);

      if(!readFile)
          cout<<"Your Transaction not process at this time\n";

      while((readFile>>au.ID>>au.pass>>au.Balance)!=NULL)

       {
            if(a==au.ID&&c==au.pass)
              {
                        cout<<"Your Account Balance Is = "<<au.Balance<<endl;
                        break;
              }

       };

       if(readFile==NULL)
                         cout<<"\n\nPassword is Wrong or Account Does not Exist";

}

int main()
{

          int AcNo;
          cout<<"================================"<<endl;
          cout<<"= WELCOME TO VIRTUAL BANK LTD. = "<<endl;
          cout<<"================================"<<endl;
          cout<<"=                              ="<<endl;
          cout<<"=                              ="<<endl;
          cout<<"= 1.  Open a New Account       ="<<endl;
          cout<<"= 2.  Open an Existing Account ="<<endl;
          cout<<"=                              ="<<endl;
          cout<<"=                              ="<<endl;
          cout<<"================================"<<endl;
          cin>>AcNo;
          if(AcNo==1)
                     openAccount();
          if(AcNo==2)
                     transaction();



      system("PAUSE");
      return 0;
}
Last edited by admin : 04-Feb-2008 at 15:16. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
  #2  
Old 04-Feb-2008, 14:03
davis
 
Posts: n/a

Re: Need Assistance in C++


...still can't bring yourself to actually ask a question, huh?

Also, are you sure that you want Balance to be an "int?"

Does that mean that in your data:

Code:
01 abc 15000 02 aaa 20000 03 1ab 500 04 xyz 12500 05 s25 25000

15000 = $150.00 (if the currency is in some form of dollars)? Or is it that it doesn't matter because you don't need to work with "cents?"

At least do all of us a favor and go (right now, not later) read the guidelines:

www.gidforums.com


:davis:
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gradebook Program - Small Problem, Need Assistance CaitlynCraft C Programming Language 3 13-Nov-2007 23:01
Desperate Need for Assistance on C Program masterspank74 C Programming Language 3 12-Mar-2007 04:06
Need assistance with looping liquidz76 CPP / C++ Forum 0 05-Dec-2006 19:05
Assistance with classes... Bravebird CPP / C++ Forum 7 27-Apr-2005 13:17
Need assistance with program DJ_Mittens C Programming Language 3 19-Apr-2005 20:15

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:53.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.