Thread: banking progrram

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    13

    Exclamation banking progrram

    hi, i made this banking program but i can't make the user specify the name of the account to be ceated here's the code i need any help and any ideas, thanks
    <code>
    #include<fstream.h>
    #include<iostream.h>
    #include <conio.h>
    #include <string.h>
    int main()
    {
    int choice;
    char crt[90];
    char eee[5];
    cout<<" Welcome to the new banking program \n";
    cout<<"---------------------------------------------------------------------\n";
    cout<<"Please choose from the below options:\n";
    cout<<"1. Create a new account.\n";
    cout<<"2. Open an existing account.\n";
    cout<<"3. Edit an existing account.\n";
    cout<<"4. Information about the programmer.\n";
    cout<<"5. Quit.\n";
    cout<<"----\n";
    cout<<"Your Choice: ";
    cin>>choice;
    cin.ignore();
    cout<<" -------------------------------------------------------------\n";
    if(choice==1)
    {
    cout<<"Please type in your account name:\n";
    cin.getline(crt, 90);
    ofstream a_file("<<crt", ios::noreplace);
    main();

    }
    }

    </code>

  2. #2
    Registered User slaveofthenet's Avatar
    Join Date
    Apr 2003
    Posts
    80
    Well, for starters you're using the deprecated headers, it should be like this:
    Code:
    #include <iostream>
    #include <fstream>
    #include <conio.h>
    //#include <string> no string library functions used
    using namespace std; //nescessary
    ...
    ofstream a_file(crt);
    Detailed understanding of language features - even of all features of a language - cannot compensate for lack of an overall view of the language and the fundamental techniques for using it. - Bjarne Stroustrup

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    8
    Also the recursion (calling main() at the end of main), should be avoided when the problem can be solved another way.

    here are my suggestions
    Code:
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    int main()
    {
      int choice;
      char crt[90];
      //char eee[5];
      // Unneccessary as of yet
    
      cout<<" Welcome to the new banking program \n";
      cout<<"---------------------------------------------------------------------\n";
      cout<<"Please choose from the below options:\n";
      cout<<"1. Create a new account.\n";
      cout<<"2. Open an existing account.\n";
      cout<<"3. Edit an existing account.\n";
      cout<<"4. Information about the programmer.\n";
      cout<<"5. Quit.\n";
      cout<<"----\n";
      cout<<"Your Choice: ";
    
      cin>>choice;
      cin.ignore();
      cout<<" -------------------------------------------------------------\n";
      if(choice==1) 
        {
          cout<<"Please type in your account name:\n"; 
          cin.getline(crt, 90); 
          ofstream a_file(crt, ios::noreplace); 
          // just crt here will do what you expect, create a file with the name crt
        }
      cout << "The name of your new account: " << crt << endl;
    
      return 0;
      //main(); recursive, and with no "break" to stop is a bad idea
    }
    Ultimately, if you plan to expand the menu and include all the options, I would reccomend that you look into the subject of Object-oriented-programming (OOP), and Classes.

    -- Placid

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Banking System
    By punnuindia in forum C++ Programming
    Replies: 9
    Last Post: 04-01-2009, 05:05 PM
  2. Replies: 5
    Last Post: 10-08-2007, 09:44 AM
  3. Banking App
    By comwiz in forum C++ Programming
    Replies: 0
    Last Post: 02-20-2006, 10:12 PM
  4. Develop new Investment Banking Trading System in Singapore
    By pclyne in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 11-14-2005, 08:32 PM