Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C++
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;

class account
{
    int accno;
    char name[50];
    int deposit;
    string type;

public:
       void create_account();
       void show_account();
       void modify();
       void dep(int);
       void draw(int);
       void report();
       int retacno();
       int retdeposit();
       string rettype();
};

   void account::create_account()
  {
   {
     ofstream accFile;
     accFile.open("new ac.txt");
     if(accFile.is_open() )
    {

     cout<<"Please enter the account number :\n"<<endl;
     cin>>accno;
     accFile << accno;

     cout<<"Enter the account holders name :\n"<<endl;
     cin>>name;
     accFile<<name;

     cout<<"Choose account type (Current/Savings):\n"<<endl;
     cin>>type;
     accFile<<type;
     cout<<"Enter initial deposit (>P250): \n"<<endl;
     cin>>deposit;
     accFile<<deposit
     accFile.close();
     }
     else
    cout<<"Unable to open file";
   }
     cout<<"\nDear Client, you account has been succesfully created";

   }


   void account::show_account()
   {
     cout<<"\n\n******************ACCOUNT DETAILS*********************\n";
     cout<<"\n\n--------------------------------------------------------------------\n";
     cout<<"ACCOUNT NAME     NAMES        ACCOUNT TYPE     ACCOOUNT BALANCE\n";
     cout<<"-----------------------------------------------------------------------\n";
     std::cin>>accno\t>>name\t>>type\t>>deposit>>;
     std::cout<<accno\t<<name\t<<type\t<<deposit<<;
   }

   void account::modify()
   {
 {   ofstream accFile;
     accFile.open("new ac.txt");
     if(accFile.is_open() )

     cout<<"\nAccount No.:" <<accno;
     cout<<"\nChange Account Holder's Name:";
     cin.getline(name,50);
     accFile<<accno;
     cout<<"\nChange Account Type:";
     cin>>type;
     accFile<<type;
     cout<<"\nAccount changes saved";
   }

    void account::dep(int a)
    {
        deposit+=a;
    }

    void account::draw(int a)
    {
        deposit-=a;
    }

    void account::report()
    {
        cout<<accno<<"\t"<<name<<"\t"<<deposit<<endl;
    }
    int account::retacno()
    {
        return accno;
    }
    int account::retdeposit()
    {
        return deposit;
    }

    string account::rettype()
    {
        return type;
    }

   void account :: create_account();	//function to write record in file
   void show_sp(int);	//function to display account details given by user
   void modify_acc(int);	//function to modify record of file
   void delete_acc(int);	//function to delete record of file
   void show_all();		//function to display all account details
   void deposit_withdraw(int, int); //

int main()
{

  char ch;
  int accnum;
  int option;
  do
  {
      system("cls");
      cout<<"\n\t WELCOME TO THE MAIN MENU";
      cout<<"***SELECT AN OPTION (1-8)***";
      cout<<"\n\t 1. NEW ACCOUNT";
      cout<<"\n\t 2. DEPOSITS";
      cout<<"\n\t  3. WITHDRAWALS";
      cout<<"\n\t  4. BALANCE ENQUIRY";
      cout<<"\n\t  5. SHOW ACCOUNT DETAILS";
      cout<<"\n\t  6. ACCOUNT CLOSURES";
      cout<<"\n\t  7. ACCOUNT MODIFICATIONS";
      cout<<"\n\t  8. EXIT";
      cin>>option;
      system("cls");

      switch(option)
    {
    case 1:
          void account:: reate_account();
           break;
    case 2:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           deposit_withdraw(accnum,1);
           break;
    case 3:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           deposit_withdraw(accnum,2);
           break;
    case 4:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           show_sp(accnum);
           break;
    case 5:
           show_all();
           break;
    case 6:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           delete_acc(accnum);
           break;
    case 7:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           modify_acc(accnum);
           break;
    case 8:
           cout<<"\n Thank You For Using Bank123";
           break;
    default :cout<<"\a";
  }
   cin.ignore();
   option = cin.get();
 }while(option != 8);

  return 0;

}


What I have tried:

I've tried basically everything and I keep getting about 50 errors in codeblocks. Please help!!
Posted
Updated 22-Aug-16 10:09am
v2
Comments
jeron1 22-Aug-16 17:18pm    
case 1:
void account:: reate_account(); <== Typo
break;
Philippe Mori 22-Aug-16 18:47pm    
Do yourself a favor of using a adequate editor and properly indent your code. It would be more obvious when { and } are not balancing.

Also, you don't seem to create any instance of account class.

You also mix C++ and C style code. It seems that many of the unimplemented "C-style" global function do something similar to the C++ member functions.

You should write only a few line of code at a time, compile them, test them, commit that your code source server and repeat again. Presently, you wrote a lot of code with many errors.

So you should start again from an empty file and add only a few lines at a time. You might start with an empty account class and an empty main function and then add one function or a few line at a time.
enhzflep 23-Aug-16 18:59pm    
There's nothing wrong with the text-editor in the Code::Blocks ide.
Philippe Mori 23-Aug-16 22:33pm    
The above code is not properly intended and { } are not balanced. Any decent editor should help find and fix that kind of problems.

1 solution

Advices:
- Use a programmer Editor, it show you parenthesis matching and can indent your code
Notepad++ Home[^]
UltraEdit: the text editor trusted by millions[^]
- indent your code, it highlight the code structure.

C is the ancestor of C++, it will not harm to read the reference book of C, the syntax of C++ comes from C.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]

In
C++
 void account::create_account()
{
 {

remove a { , it should remove a couple errors.

[Update]
C++
case 1:
      void account:: reate_account();
       break;

This code show that you barely understand what you do.
Nota: it is create

Advice: follow tutos before doing your own projects.

[Update]
CodeBlocks is an advanced editor, feature rich.
It is a good idea to learn how to use them, those features are here to help you.
 
Share this answer
 
v3
Comments
Member 12697792 22-Aug-16 17:09pm    
Thank you, can you help me with the functions i am to use to turn the code into a fully running one?
Philippe Mori 22-Aug-16 18:48pm    
Fix one error at a time until you have no errors.
enhzflep 23-Aug-16 19:12pm    
There's nothing wrong with the text-editor in the Code::Blocks ide. In fact, in many ways its superior to Notepad++.

Case in point: try right-clicking an identifier in N++ and selecting any of the following options: "Open containing folder", "Format use AStyle", "Find implementation of: ", "Find functions calling: "

Exactly - it doesn't have any of them, nor any concept of projects. It's an amazing editor, thanks to it's use of the Scintilla dll - but plenty of other editors use the same syntax highlighting engine too.

My +4
Patrice T 23-Aug-16 19:37pm    
Ok, I see your point. It looks like the problem is to learn to use the editor's helps rather than not having the features.
By the way I didn't say or thought that CodeBlocks is not good (Even if I don't use it)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900