Solved

More errors i don't know how to fix

Posted on 2001-06-05
11
283 Views
Last Modified: 2010-04-02
Ok, heres my latest problem, originally I had this program working with the majority of the code in the header file, unfortunately I cant get it to work outside the header file, (im using Borland c++ v3)

Here are the compile errors

Compiling BANK1G.CPP:
Error MYBANK.HPP 12: Declaration terminated incorrectly
Error BANK1G.CPP 13: Declaration syntax error in function BankAccount::Get_Bal()
Error BANK1G.CPP 334: Type qualifier 'BankDB' must be a struct or class name in function BankAccount::Get_Bal()
Error BANK1G.CPP 334: Declaration terminated incorrectly in function BankAccount::Get_Bal()
Error BANK1G.CPP 553: Declaration missing ; in function BankAccount::Get_Bal()


Here is the main .cpp file

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <fstream.h>
#include <io.h>
#include <process.h>
#include <stdlib.h>
#include "mybank.hpp"

void main()
{

float totalbalances;
BankDB bankdb;

char option;
bankdb.clear();
clrscr();

do{

clrscr();
cout <<"\t\t\tWelcome to the Royal Bank of Cheshire";
cout <<"\n\n\tPlease select the appropriate option below:";
cout <<"\n\t #1.# Open An Account At The Royal Bank Of Cheshire";
cout <<"\n\t #2.# Credit An Account By Surname";
cout <<"\n\t #3.# Credit An Account By Account Number";
cout <<"\n\t #4.# Withdraw Money From An Account By Surname";
cout <<"\n\t #5.# Withdraw Money From An Account By Account Number";
cout <<"\n\t #6.# Display All Royal Bank of Cheshire Accounts ";
cout <<"\n\t #0.# Adminastrative Options";
cout <<"\n\n\t #7.# Quit\nOption: ";
cin >>option;

if (option=='1') {
      cout <<"\nOpening An Account";
      bankdb.Add_Customer();
      getch();
}

if (option=='2') {
      cout <<"Crediting An Account By Surname";
      bankdb.Add_To_Bal_By_Name();
      getch();
}

if (option=='3') {
      cout <<"Crediting An Account By Account Number";
      bankdb.Add_To_Bal_By_Number();
      getch();
}

if (option=='4') {
      cout <<"Withdrawing Money From An Account By Surname";
      bankdb.Subtract_Bal_By_Name();
      getch ();
}

if (option=='5') {
      cout <<"Withdrawing Money From An Account By Number";
      bankdb.Subtract_Bal_By_Num();
      getch() ;
}

if (option=='6') {
      clrscr();
      bankdb.Show_All_Accounts();
      getch();
}

if (option=='0') {
      clrscr();
      cout <<"\n\t\tYou are cuurently in the Adminastrative Options\n";
      cout <<"\tPlease select the appropriate option below:";
      cout <<"\n\t\t #l.# Add To An Account Ballance By Number";
      cout <<"\n\t\t #2.# Add To An Account Ballance By Surname";
      cout <<"\n\t\t #3.# Subtract From An Account Balance By Number";
      cout <<"\n\t\t #4.# Subtract From An Account Balance By Surname";
      cout <<"\n\t\t #5.# Return An Account Ballance By Number";
      cout <<"\n\t\t #6.# Return An Account Ballance By Surname";
      cout <<"\n\t\t #7.# Return An Account Name By Number";
      cout <<"\n\t\t #8.# Show All Royal Bank of Cheshire Accounts\n";
      cout <<"\n\t\t #9.# Restore The Account Database";
      cout <<"\n\t\t #0.# Craate A Backup Of The Account Database\n";
      cout <<"\n\t\t #q.# End Session";
      cout <<"\n\tOption:";
      cin >>option;

if (option=='1') {
      bankdb.Add_To_Bal_By_Number();
      getch();
}

else if (option=='2' ) {
      bankdb.Add_To_Bal_By_Name();
      getch();
}

else if (option=='3') {
      bankdb.Subtract_Bal_By_Num();
      getch();
}

else if (option=='4') {
      bankdb.Subtract_Bal_By_Name();
      getch();
}

else if (option=='5') {
      bankdb.Return_Bal_By_Number();
      getch();
}

else if (option=='6') {
      bankdb.Return_Bal_By_Name();
      getch();
}

else if (option=='7') {
      bankdb.Return_Acc_Name_By_Number();
      getch ();
}

else if (option=='8') {
      bankdb.Show_All_Accounts();
      getch();
}

else if (option=='9') {
      bankdb.readDB();
}

else if (option=='0') {
      bankdb.writeDB();
}

else if (option=='q') {
      cout <<"test";
}

else {
      cout <<" \n\t\t\tUnfortunatley Your Inputed Option Was Incorect, Please Try Again \n";
      getch () ;
}

getch() ;
}
}
while(option! ='7');
cout <<"Ending Session";
}

//-------------------------------------------------~~-------------------------
//****************************************************************************
//-------------------------------------------------------------------------

void BankAccount::Clear_All() {
      balance=0;
      strcpy(name,blank) ;
}


//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------


void BankAccount::Name_Is_Set_To() {
      cout <<"\nPlease Enter The Surname Of The Account";
      scanf ("%s",name);
      balance=0;
}

//------------------------------------~-----------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Add_To_Bal() {
      cout <<"\nPlease Enter The Desired Quantity Of Money You Wish To Credit The Account With "<<name;

//End of page 1 <><> End of page 1 <><> End of page 1 <><> End of page 1 <><>

//start of page 2 <><> start of page 2 <><> start of page 2 <><> start of page 2

      cin >>Input;
      balance=balance+Input;
      totalbalances=totalbalances+Input;
      cout <<"\nThank You,";
      cout <<"\n\n The total of thc account "<<name " is now: ?"<<balance;
      getch() ;
}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Subtract_Bal() {
      cout <<"\nPlease Enter The Desired Quantity Of Money You Wish To Withdraw From The Account "<<name;
      cin >>Input;
      balance=balance-Input;
      totalbalances=totalbalances-Input;
      cout <<"\nThank You,";
      cout <<"\n\nThe Current Balance Of The Account "<<name " is now: ?"<<balance;
      getch();
}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Return_Acc_Bal() {
      cout <<"\nThe Bccount Belonging To Mr/Mrs "<<name<<" has a total balance of:\n\t\t?"<<balance;
      getch();
}

//----------------------------~--------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Return_Acc_Name() {
      cout <<"\nThe Account Is entered Currently In The Name Of Mr/Mrs "<<name;
      getch();
}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Clear_Tot_Balances() {
      cout <<" \nThe Current Ballance On This System Has Been Reset To ?0";
      totalbalances=0;
}

//-----------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Add_To_Tot_Balances() {
      cout <<"\nTo Add To The Current Total Of Balances Please Enter The";
      cout <<"?";
      cin >>Input;
      totalbalances=totalbalances+Input;
}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Return_Tot_Bal() {
      cout <<"The Total Of Balancess That Currently Occupy The Royal Bank Of Cheshire is ?"<<totalbalances;
}

//----------------------------------------------------------------------------
//****************************************************************************
//-------------------------~-----------------------------------------------

void BankAccount::Get_Name_By_Number() {
      cout <<"\nThe Surname Of The Account Holder is:" ;
      printf("%s",name) ;
}

//----------------------------------------------------------------------------
//****************************************************************************
//End of page 2 <><> End of page 2 <><> End of page 2 <><> End of page 2 <><>

//Start of Page 3 <><> Start of Page 3 <><> Start of Page 3 <><> Start of Page 3 <><>
//------------------------------------------------------------------~~--------

void BankAccount::Account_Info() {
      cout <<"Account Information: \n";
      cout <<"\n\t\tAccount Name:";
      printf ("%s", name) ;
      cout <<"\n\t\tAccount Balance ?"<<balance;
      cout <<"Please press any key to see the next account... \n";
      getch() ;
}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

char* BankAccount::Get_Name() {
return (name);
}

//-----------------~~~~-------------------------------------------------------
//**************************************************************************
//----------------------------------------------------------------------------

void BankAccount::Get_Name(char* Acc_Name) {
      char acname[20];
      strcpy(acname,Acc_Name) ;
      strcpy(name,acname) ;
}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankAccount::DB_Bal(long Acc_Bal) {
      balance=Acc_Bal;
}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

class BankDB::BankAccount {
private:

public:

void Clear();
void Add_Customer();
void Add_To_Bal_By_Number () ;
void Add_To_Bal_By_Name();
void Subtract_Bal_By_Num();
void Subtract_Bal_By_Name();
void Return_Bal_By_Number();
void Return_Bal_By_Name();
void Return_Acc_Name_By_Number();
void Show_All_Accounts();
void readDB();
void writeDB();
BankAccount bankaccount[20];
int i;
int Account_Number;
char *namesearch;
char test;

} ;
void BankDB::clear() {
int i=0;
for(i=0;i<=20;i++) {
      bankaccount[i].Clear_All();
      }
      cout <<"test";
      }
//End of page 3 <><> End of page 3 <><> End of page 3 <><> End of page 3 <><>
//Start of page 4 <><> Start of page 4 <><> Start of page 4 <><> Start of page 4 <><>

void BankDB::Add_Customer() {
      cout <<" \nPlease Enter The Account Number:";
      cin >>i;
      bankaccount[i].Name_Is_Set_To();
}
//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------



//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankDB::Add_To_Bal_By_Number() {
      cout <<" \nPlease Enter The Account Number: ";
      cin >>i;
      bankaccount[i].Add_To_Bal();
      }
//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankDB::Add_To_Bal_By_Name() {
int i=O;
int test;
char retname[20];
      cout <<"Please Enter The Surname:";
      scant (" %s" f namesearch) ;
      for (i=O;i<=20;i++) {
      strcpy (retname, bankaccount [i] . getrlame ( ) ) ;
      test= strcmpi(namesearch,retname);
      if (test==O) {
      cout <<"The Account Number Is :"
      break;
}
}
      bankaccount[i].Add_To_Bal();

}

//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankDB::Subtract_Bal_By_Num() {
cout <<"\nPlease Enter The Account Number:";
cin>>i;
bankaccount[i].Subtract_Bal();
}
//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankDB::Subtract_Bal_By_Name() {
char retname[20];
int i=O;
      cout <<" Please enter the name: ";
      scant ("%s", namesearch) ;
      for (i=O;i<=20;i++) {
      strcpy(retname,bankaccount[i].Get_Name());
      test= strcmpi(namesearch,retname);
//End of page 4 <><> End of page 4 <><> End of page 4 <><> End of page 4 <><>
//Start of page 5 <><> Start of page 5 <><> Start of page 5 <><> Start of page 5 <><>
      if (test==O) {
      cout <<"The Account Number is :" <<i <<" \n";
break;
}
}
      bankaccount[i].Subtract_Bal();
}
//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------
void BankDB::Return_Bal_By_Number() {
      cout <<" \nPlease Enter The Account Number: ";
      cin>>i;
      bankaccount[i].Return_Acc_Bal();
}
//----------------------------------------------------------------------------
//****************************************************************************
//-------------~~~------------------------------------------------------------
void BankDB::Return_Bal_By_Name() {
char retname[20];
int i=O;
      cout <<"Please Enter The Surname:";
      scanf ("%s", namesearch) ;
      for (i=O;i<=20;i++) {
      strcpy(retname,bankaccount[i] .getnarne());
      test= strcmpi(namesearch,retname);
      if (test==O) {
      cout <<"The Account number is :" <<i <<"\n";
break;
}
}
bankaccount[i].return account balance();
}
//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------
void BankDB::Return_Acc_Name_By_Number() {
      cout <<" \nPlease Enter The Account Number: ";
      cin >>i;
      bankaccount[i].Get_Name_By_Number();
}

//----------------------------------------------------------------------------
//****************************************************************************

//----------------------------------------------~~~~~-------------------------
void BankDB::Show_All_Accounts() {
      cout <<"Please Enter The Number Of Accounts That You Wish To See:";
      cin >>Input;
      Input=Input-l;
      for (i=O;i<=Input;i++) {
      bankaccount[i].Account_Info();
}
}
//--------------------------~~~~~---------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------
void BankDB::readDB() {
clrscr() ;
char filenm[60], Acc_Name[20], Acc_Bal[20], inc;
long int acctot = 0;
int account count = 0, char count = 0;
int accno=O;
      FILE* infile;
//End of page 5 <><> End of page 5 <><> End of page 5 <><> End of page 5 <><>

//Start of page 6 <><> Start of page 6 <><> Start of page 6 <><>
      strcpy (filenm, "g: \\filedata. txt") ;
      infile = fopen (filenm, "r");
      if(!infile)
{
      cout<<"ERROR!!! ---> Unfortunatley The Input File Can't Be Opened";
      exit(1) ;
}

      Acc_Name [0] - '\0';
      do
{
      char_count = 0;
      while (inc = fgetc(infile))
{
      if ( inc == ',')
      break;
      Acc_Name[char_count++] = inc;
}
      Acc_Name[char_count] = '\0';
      cout <<"\n" ;
      if (inc != EOF)
{
      char count - 0;
      while (in~ - fgetc(infile))
{
      if ((inc == '\n') || (inc == EOF))
break;
      Acc_Bal[char_count++] = inc;
}
      Acc_Bal[char_count++] = '\0';

      bankaccount[accno].Get_Name(Acc_Name);
      bankaccount[accno].DB_Bal(atol(Acc_Bal));
      account_count++;
      accno++;
}
}while (inc != EOF);
      cout << "\nAccounts read = "<< account_count;
      cout << " \nAcounts total = " << acctot;
      cout << "\n\t\t\tData read and inputed";

fclose(infile);
}
//----------------------------------------------------------------------------
//****************************************************************************
//----------------------------------------------------------------------------

void BankDB::writeDB() {
clrscr() ;
char retname[20];
float bal=0;
int error;
fstream fs;
fs.open("g:\\bankdatatest.txt",ios::out);
clrscr() ;
error==fs.good();
//End of page 6 <><> End of page 6 <><> End of page 6 <><> End of page 6 <><>

//Start of page 7 <><> Start of page 7 <><> Start of page 7 <><> Start of page 7 <><>
      if(error==0) {
      cout <<"Error openlng file";
}
      else{
      int i=0;
      for (i=0;i<=20;i++) {
      strcpy(retname,bankaccount[i].Get_Name(
      bal=bankaccount[i].Get_Bal();
      fs<<retname;
      fs<<",";
      fs<<bal;
      fs<<"\n";
}

}

fs.close();
}
}
//End of page 7 <><> End of page 7 <><> End of page 7 <><> End of page 7 <><>



and here is the header file mybank.hpp

class BankAccount {

private:
char surname[20];
float balance;

public:

void Account_Info();
void Add_To_Bal();
void Add_To_Tot_Balances()
void Clear_All();
void Clear_Tot_Balances();
void DB_Bal(long Acc_Bal);
void Get_Name_By_Number();
void Get_Name(char* Acc_Name);
void Name_Is_Set_To();
void Return_Acc_Bal();
void Return_Acc_Name();
void Return_Tot_Bal();
void Subtract_Bal();
char* Get_Name();
float Get_Bal();
float Input;
} ;
float BankAccount::Get_Bal() {
return (balance);



0
Comment
Question by:pengwinzz
11 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 6156377
I'm not sure about all of them. But there seem to be two errors in the hpp file:

No terminating semicolon on:

void Add_To_Tot_Balances()

and no terminating brace on:

float BankAccount::Get_Bal() {
return (balance);



0
 
LVL 5

Expert Comment

by:proskig
ID: 6156429
At first glance: the very end:

float BankAccount::Get_Bal() {
return (balance);


Where is closing bracket?
0
 
LVL 1

Expert Comment

by:LDC
ID: 6156603
imladris is right,
Missing semicolon and curly brace.

I can't help suggesting you use switch instead of all yoour if (options == '') or at least a if else. Your program'll run much faster.
0
 

Expert Comment

by:irisistable
ID: 6156772
hi,

i read your code until the middle and found some syntax errors and some style issues. there are probaby more syntax errors in the part that i haven't read, but i think that following the compile errors shall help you solve them easily... here are things that i found :

errors :
1)in function BankAccount::Subtract_Bal() in line 6 there is a << missing.

2)in BankDB::clear() there is a loop that runs from 0 until and equal to 20 (<=20), while it should not include 20 (<20). this can cause a run time error. this problem returns in many places in the code.

3)in BankDB::Add_To_Bal_By_Name() there is usage of the letter O while you probably meant to put the digit 0 (in two places in that function and in many other places in the code) and also in that function there is the problem with the loop like i wrote above, and also there is a comma missing in the scanf after the "%s"

4) in methods of class BankAccount you use a data member called 'name', but i haven't seen such a data member in the class declaration.

Style issues :
1) you are using clrscr() ans getch() which are not ANSIC (unless that changed and i don't know about it...).

2) you write expressions like balance = balance + input;
instead of balance += input; using += -= *= etc will save you time at run time.

3) in some places you have cin and cout, and in others you have printf and scanf, that is not consistent

4) it is much nicer to use 'switch' statement in case of all the 'if'

5)it will be nice to have an enum instead of all the numbers. it will ease the process of modifying the code later

So.... follow the compile erros, they lead you to the line with the problem and you can solve the rest easily :)
0
 

Expert Comment

by:irisistable
ID: 6156782
Also, you have data members in your 'public' section. it is a good idea to keep all your data members as 'private' so that you can monitor changes to them (otherwise, any silly function that gets hold on your objects can ruin the value in their data members... need to protect them)
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:pengwinzz
ID: 6160080
heres how it looks now

Compiling BANK2K.CPP:
Warning MYBANK.HPP 28: Cannot create pre-compiled header: code in header
Error BANK2K.CPP 16: Undefined symbol 'BankDB' in function main()
Error BANK2K.CPP 16: Statement missing ; in function main()
Error BANK2K.CPP 18: Identifier 'Get_Name' cannot have a type qualifier in function main()
Error BANK2K.CPP 23: Undefined symbol 'bankdb' in function main()
Error BANK2K.CPP 39: Undefined symbol 'option' in function main()
Error BANK2K.CPP 155: Do-while statement missing ) in function main()
Warning BANK2K.CPP 157: 'totalbalances' is declared but never used in function main()
Error BANK2K.CPP 172: Undefined symbol 'totalbalances' in function BankAccount::Add_To_Bal()
Error BANK2K.CPP 174: Statement missing ; in function BankAccount::Add_To_Bal()
Error BANK2K.CPP 182: Undefined symbol 'totalbalances' in function BankAccount::Add_To_Tot_Balances()
Error BANK2K.CPP 187: Undefined symbol 'blank' in function BankAccount::Clear_All()
Error BANK2K.CPP 192: Undefined symbol 'totalbalances' in function BankAccount::Clear_Tot_Balances()
Error BANK2K.CPP 227: Undefined symbol 'totalbalances' in function BankAccount::Return_Tot_Bal()
Error BANK2K.CPP 234: Undefined symbol 'totalbalances' in function BankAccount::Subtract_Bal()
Error BANK2K.CPP 240: Type qualifier 'BankDB' must be a struct or class name
Error BANK2K.CPP 264: Type qualifier 'BankDB' must be a struct or class name
Error BANK2K.CPP 264: Declaration terminated incorrectly
Error BANK2K.CPP 435: Unexpected }

eeeep!!!


main .cpp file


#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <fstream.h>
#include <io.h>
#include <process.h>
#include <stdlib.h>
#include "mybank.hpp"

void main()
{

float totalbalances;
BankDB bankdb;

char* BankAccount::Get_Name() {
return (surname);
}

char option;
bankdb.clear();
clrscr();

do{

clrscr();
cout <<"\t\t\tWelcome to the Royal Bank of Cheshire";
cout <<"\n\n\tPlease select the appropriate option below:";
cout <<"\n\t #1.# Open An Account At The Royal Bank Of Cheshire";
cout <<"\n\t #2.# Credit An Account By Surname";
cout <<"\n\t #3.# Credit An Account By Account Number";
cout <<"\n\t #4.# Withdraw Money From An Account By Surname";
cout <<"\n\t #5.# Withdraw Money From An Account By Account Number";
cout <<"\n\t #6.# Display All Royal Bank of Cheshire Accounts ";
cout <<"\n\t #0.# Adminastrative Options";
cout <<"\n\n\t #7.# Quit\nOption: ";
cin >>option;

if (option=='1') {
      cout <<"\nOpening An Account";
      bankdb.Add_Customer();
      getch();
}

if (option=='2') {
      cout <<"Crediting An Account By Surname";
      bankdb.Add_To_Bal_By_Name();
      getch();
}

if (option=='3') {
      cout <<"Crediting An Account By Account Number";
      bankdb.Add_To_Bal_By_Number();
      getch();
}

if (option=='4') {
      cout <<"Withdrawing Money From An Account By Surname";
      bankdb.Subtract_Bal_By_Name();
      getch ();
}

if (option=='5') {
      cout <<"Withdrawing Money From An Account By Number";
      bankdb.Subtract_Bal_By_Num();
      getch() ;
}

if (option=='6') {
      clrscr();
      bankdb.Show_All_Accounts();
      getch();
}

if (option=='0') {
      clrscr();
      cout <<"\n\t\tYou are cuurently in the Adminastrative Options\n";
      cout <<"\tPlease select the appropriate option below:";
      cout <<"\n\t\t #l.# Add To An Account Ballance By Number";
      cout <<"\n\t\t #2.# Add To An Account Ballance By Surname";
      cout <<"\n\t\t #3.# Subtract From An Account Balance By Number";
      cout <<"\n\t\t #4.# Subtract From An Account Balance By Surname";
      cout <<"\n\t\t #5.# Return An Account Ballance By Number";
      cout <<"\n\t\t #6.# Return An Account Ballance By Surname";
      cout <<"\n\t\t #7.# Return An Account Name By Number";
      cout <<"\n\t\t #8.# Show All Royal Bank of Cheshire Accounts\n";
      cout <<"\n\t\t #9.# Restore The Account Database";
      cout <<"\n\t\t #0.# Craate A Backup Of The Account Database\n";
      cout <<"\n\t\t #q.# End Session";
      cout <<"\n\tOption:";
      cin >>option;

if (option=='1') {
      bankdb.Add_To_Bal_By_Number();
      getch();
}

else if (option=='2' ) {
      bankdb.Add_To_Bal_By_Name();
      getch();
}

else if (option=='3') {
      bankdb.Subtract_Bal_By_Num();
      getch();
}

else if (option=='4') {
      bankdb.Subtract_Bal_By_Name();
      getch();
}

else if (option=='5') {
      bankdb.Return_Bal_By_Number();
      getch();
}

else if (option=='6') {
      bankdb.Return_Bal_By_Name();
      getch();
}

else if (option=='7') {
      bankdb.Return_Acc_Name_By_Number();
      getch ();
}

else if (option=='8') {
      bankdb.Show_All_Accounts();
      getch();
}

else if (option=='9') {
      bankdb.readDB();
}

else if (option=='0') {
      bankdb.writeDB();
}

else if (option=='q') {
      cout <<"test";
}

else {
      cout <<" \n\t\t\tUnfortunatley Your Inputed Option Was Incorect, Please Try Again \n";
      getch () ;
}

getch() ;
}
}
while(option! ='7');
cout <<"Ending Session";
}

void BankAccount::Account_Info() {
      cout <<"Account Information: \n";
      cout <<"\n\t\tAccount Name:";
      printf ("%s", surname) ;
      cout <<"\n\t\tAccount Balance ?"<<balance;
      cout <<"Please press any key to see the next account... \n";
      getch() ;
}

void BankAccount::Add_To_Bal() {
      cout <<"\nPlease Enter The Desired Quantity Of Money You Wish To Credit The Account With "<<surname;
      cin >>Input;
      balance=balance+Input;
      totalbalances=totalbalances+Input;
      cout <<"\nThank You,";
      cout <<"\n\n The total of thc account " <<surname " is now: ?" <<balance;
      getch() ;
}

void BankAccount::Add_To_Tot_Balances() {
      cout <<"\nTo Add To The Current Total Of Balances Please Enter The";
      cout <<"?";
      cin >>Input;
      totalbalances=totalbalances+Input;
}

void BankAccount::Clear_All() {
      balance=0;
      strcpy(surname,blank) ;
}

void BankAccount::Clear_Tot_Balances() {
      cout <<" \nThe Current Ballance On This System Has Been Reset To ?0";
      totalbalances=0;
}

void BankAccount::DB_Bal(long Acc_Bal) {
      balance=Acc_Bal;
}

void BankAccount::Get_Name_By_Number() {
      cout <<"\nThe Surname Of The Account Holder is:" ;
      printf("%s",surname) ;
}

void BankAccount::Get_Name(char* Acc_Name) {
      char acname[20];
      strcpy(acname,Acc_Name) ;
      strcpy(surname,acname) ;
}

void BankAccount::Name_Is_Set_To() {
      cout <<"\nPlease Enter The Surname Of The Account";
      scanf ("%s",surname);
      balance=0;
}

void BankAccount::Return_Acc_Bal() {
      cout <<"\nThe Bccount Belonging To Mr/Mrs "<<surname<<" has a total balance of:\n\t\t?"<<balance;
      getch();
}

void BankAccount::Return_Acc_Name() {
      cout <<"\nThe Account Is entered Currently In The Name Of Mr/Mrs "<<surname;
      getch();
}

void BankAccount::Return_Tot_Bal() {
      cout <<"The Total Of Balancess That Currently Occupy The Royal Bank Of Cheshire is ?" <<totalbalances;
}

void BankAccount::Subtract_Bal() {
      cout <<"\nPlease Enter The Desired Quantity Of Money You Wish To Withdraw From The Account "<<surname;
      cin >>Input;
      balance=balance-Input;
      totalbalances=totalbalances-Input;
      cout <<"\nThank You,";
      cout <<"\n\nThe Current Balance Of The Account "<<surname <<" is now: ?"<<balance;
      getch();
}

class BankDB::BankAccount {
private:

public:

void Clear();
void Add_Customer();
void Add_To_Bal_By_Number () ;
void Add_To_Bal_By_Name();
void Subtract_Bal_By_Num();
void Subtract_Bal_By_Name();
void Return_Bal_By_Number();
void Return_Bal_By_Name();
void Return_Acc_Name_By_Number();
void Show_All_Accounts();
void readDB();
void writeDB();
BankAccount bankaccount[20];
int i;
int Account_Number;
char *namesearch;
char test;

} ;
void BankDB::clear() {
int i=0;
for(i=0;i<21;i++) {
      bankaccount[i].Clear_All();
      }
      cout <<"test";
      }

void BankDB::Add_Customer() {
      cout <<" \nPlease Enter The Account Number:";
      cin >>i;
      bankaccount[i].Name_Is_Set_To();
}

void BankDB::Add_To_Bal_By_Number() {
      cout <<" \nPlease Enter The Account Number: ";
      cin >>i;
      bankaccount[i].Add_To_Bal();
      }

void BankDB::Add_To_Bal_By_Name() {
int i=0;
int test;
char retname[20];
      cout <<"Please Enter The Surname:";
      scanf (" %s", f namesearch) ;
      for (i=0;i<=20;i++) {
      strcpy (retname, bankaccount [i] . getrlame ( ) ) ;
      test= strcmpi(namesearch,retname);
      if (test==0) {
      cout <<"The Account Number Is :"
      break;
}
}
      bankaccount[i].Add_To_Bal();
}

void BankDB::Subtract_Bal_By_Num() {
cout <<"\nPlease Enter The Account Number:";
cin>>i;
bankaccount[i].Subtract_Bal();
}

void BankDB::Subtract_Bal_By_Name() {
char retname[20];
int i=0;
      cout <<" Please enter the name: ";
      scanf ("%s", namesearch) ;
      for (i=0;i<=20;i++) {
      strcpy(retname,bankaccount[i].Get_Name());
      test= strcmpi(namesearch,retname);
      if (test==0) {
      cout <<"The Account Number is :" <<i <<" \n";
break;
}
}
      bankaccount[i].Subtract_Bal();
}

void BankDB::Return_Bal_By_Number() {
      cout <<" \nPlease Enter The Account Number: ";
      cin>>i;
      bankaccount[i].Return_Acc_Bal();
}

void BankDB::Return_Bal_By_Name() {
char retname[20];
int i=0;
      cout <<"Please Enter The Surname:";
      scanf ("%s", namesearch) ;
      for (i=0;i<=20;i++) {
      strcpy(retname,bankaccount[i] .getnarne());
      test= strcmpi(namesearch,retname);
      if (test==0) {
      cout <<"The Account number is :" <<i <<"\n";
break;
}
}
bankaccount[i].return account balance();
}

void BankDB::Return_Acc_Name_By_Number() {
      cout <<" \nPlease Enter The Account Number: ";
      cin >>i;
      bankaccount[i].Get_Name_By_Number();
}

void BankDB::Show_All_Accounts() {
      cout <<"Please Enter The Number Of Accounts That You Wish To See:";
      cin >>Input;
      Input=Input-l;
      for (i=0;i<=Input;i++) {
      bankaccount[i].Account_Info();
}
}

void BankDB::readDB() {
clrscr() ;
char filenm[60], Acc_Name[20], Acc_Bal[20], inc;
long int acctot = 0;
int account count = 0, char count = 0;
int accno=0;
      FILE* infile;
      strcpy (filenm, "g:\\data.txt");
      infile = fopen (filenm, "r");
      if(!infile)
{
      cout<<"ERROR!!! ---> Unfortunatley The Input File Can't Be Opened";
      exit(1) ;
}

      Acc_Name [0] - '\0';
      do
{
      char_count = 0;
      while (inc = fgetc(infile))
{
      if ( inc == ',')
      break;
      Acc_Name[char_count++] = inc;
}
      Acc_Name[char_count] = '\0';
      cout <<"\n" ;
      if (inc != EOF)
{
      char count - 0;
      while (in~ - fgetc(infile))
{
      if ((inc == '\n') || (inc == EOF))
break;
      Acc_Bal[char_count++] = inc;
}
      Acc_Bal[char_count++] = '\0';

      bankaccount[accno].Get_Name(Acc_Name);
      bankaccount[accno].DB_Bal(atol(Acc_Bal));
      account_count++;
      accno++;
}
}while (inc != EOF);
      cout << "\nAccounts read = "<< account_count;
      cout << " \nAcounts total = " << acctot;
      cout << "\n\t\t\tData read and inputed";
fclose(infile);
}

void BankDB::writeDB() {
      clrscr() ;
      char retname[20];
      float bal=0;
      int error;
      fstream fs;
      fs.open("g:\\bankdata.txt",ios::out);
      clrscr() ;
      error==fs.good();
      if(error==0) {
      cout <<"Error openlng file";
}
      else{
      int i=0;
      for (i=0;i<=20;i++) {
      strcpy(retname,bankaccount[i].Get_Name(
      bal=bankaccount[i].Get_Bal();
      fs<<retname;
      fs<<",";
      fs<<bal;
      fs<<"\n";
}
}
fs.close();
}
}



header file

class BankAccount

{

private:
char surname[20];
float balance;

public:

void Account_Info();
void Add_To_Bal();
void Add_To_Tot_Balances();
void Clear_All();
void Clear_Tot_Balances();
void DB_Bal(long Acc_Bal);
void Get_Name_By_Number();
void Get_Name(char* Acc_Name);
void Name_Is_Set_To();
void Return_Acc_Bal();
void Return_Acc_Name();
void Return_Tot_Bal();
void Subtract_Bal();
char* Get_Name();
float Get_Bal();
float Input;
} ;
float BankAccount::Get_Bal() {
return (balance);
}

Ive never used switch statments before (still newbie) and i'll try changing the if's to switches when the prog works

As for the "+=" thats not the way im being taught to use c++ and im not 100% sure that they'll work with borland c++ v3

and what are "enum"

0
 

Accepted Solution

by:
andrewls earned 50 total points
ID: 6162724
Hi Pengwinzz,

Below are some errors you need to fix:

Error MYBANK.HPP 12: Declaration terminated incorrectly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Add a ; to the end of line 12 in mybank.hpp.

Before:
void Add_To_Tot_Balances()

After:
void Add_To_Tot_Balances();


BankAccount::Get_Bal() Implementation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following is down the bottom of the header file:

float BankAccount::Get_Bal() {
                    return (balance);

You are missing a closing brace ('}').

After:
float BankAccount::Get_Bal() {
                    return (balance);
}


Undefined BankDB
~~~~~~~~~~~~~~
BankDB, at line 16 of bank1g.cpp has not been defined.  Is this meant to be BankAccount?

There will probably be some more errors, however I will need to you to fix the above errors first.
0
 

Expert Comment

by:irisistable
ID: 6162747
hi,

the errors are simple, just go to the lines that it mentions and make simple changes, sometimes it tells you exactly what is wrong (no ';' for example). it is not a good idea to ask for help with this kind of thing, you really should solve the compilation errors by yourself.

about the += ans alike, i don't see any reason why it shouldn't work. i=i+4; is exactly like i+=4; only that the second time takes less time to perform during run time.

enum is something like :
enum {exit, add, subtract, divide, multiply};
which makes the words that are written in the {} to be interpreted by the computer to numbers.
in this example, exit is like 0, add is like 1, subtract is like 2, divide is like 3 and so on. so in the code, instead of saying
if(i == 1)
you can say
if (i == add)
which is more readable and makes it easier to change things later.

good luck with the compilation errors fixing :)
0
 

Expert Comment

by:andrewls
ID: 6162748
An enum allows you to define a list of possible options.

For example:

enum Colours { BLACK, BLUE, GREE };

Colours colour = BLUE;
0
 

Expert Comment

by:andrewls
ID: 6162752
Sorry, I'm new to this.  I didn't realise someone else was helping you.
0
 

Expert Comment

by:irisistable
ID: 6162760
hi,

the errors are simple, just go to the lines that it mentions and make simple changes, sometimes it tells you exactly what is wrong (no ';' for example). it is not a good idea to ask for help with this kind of thing, you really should solve the compilation errors by yourself.

about the += ans alike, i don't see any reason why it shouldn't work. i=i+4; is exactly like i+=4; only that the second time takes less time to perform during run time.

enum is something like :
enum {exit, add, subtract, divide, multiply};
which makes the words that are written in the {} to be interpreted by the computer to numbers.
in this example, exit is like 0, add is like 1, subtract is like 2, divide is like 3 and so on. so in the code, instead of saying
if(i == 1)
you can say
if (i == add)
which is more readable and makes it easier to change things later.

good luck with the compilation errors fixing :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now