Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Maintain bank record. (http://www.go4expert.com/forums/maintain-bank-record-t19214/)

kpsg25690 28Aug2009 22:34

Maintain bank record.
 
C++ program to maintain bank record.

The program is not complete as there are a couple of options to be added but the program now should and does run except a little problem with two statements.
the statements commented do not show up on the output screen and generates warnings


Code:

       
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>

class bank
{
private:
int accno,sum,x;
char name[50];
public:
bank()
{
x=0;
}

void getdata()
{
        cout<<"\nEnter the name of the account holder:";
        gets(name);
        cout<<"\nEnter the account number:";
        cin>>accno;
        cout<<"\nEnter the sum already in the account:";
        cin>>sum;
}
void showdata()
        {
        cout<<"\nThe name of the account holder:";
        puts(name);
        cout<<"\nThe account number:";
        cout<<accno;
        cout<<"\nThe sum already in the account:";
        cout<<sum;

        }
void deposit();
void withdraw();
}s[10];
void bank::deposit()
{
cout<"\nEnter the sum you want to deposit:";    //warning:code has no effect.
cin>>x;
sum+=x;
}
void bank::withdraw()
{
cout<"\nEnter the sum you want to withdraw:";  //warning:code has no effect
cin>>x;
sum-=x;
}

void main()
{
clrscr();
int n,k;
char ch='y';
cout<<"\n\t\tBANK RECORD KEEPING SYSTEM\n";
cout<<"\nEnter the number of records you want to store(max. 10):";
cin>>n;
while(ch=='y')
{

cout<<"\n1.Enter record";
cout<<"\n2.Display record";
cout<<"\n3.Withdraw funds";
cout<<"\n4.Deposit funds";
cout<<"\n5.Exit\n";
cin>>k;
if(k==1)
        {
        for(int i=1;i<=n;i++)
                {
                s[i].getdata();
                }
        }
if(k==2)
        {
        for(int i=1;i<=n;i++)
                {
                s[i].showdata();
                }
        }
else
if(k==3)
        {
        for(int i=1;i<=n;i++)
                {

                s[i].withdraw();
                }
        }
else
if(k==4)
        {
        for(int i=1;i<=n;i++)
                {
                s[i].deposit();
                }
        }
else
if(k==5)
        {
        exit(0);
        }
cout<<"\nDo you want to go back to the menu(y/n):";
ch=getche();
}
getche();
}



c_user 30Aug2009 05:30

Re: Maintain bank record.
 
In line no..42 and 48 u hav forgot the '<' while writting the cout
check out for the syntax...
use
using namespace std;
for less errors..
a very gud programming....
hav a gud day.....

c_user 30Aug2009 05:32

Re: Maintain bank record.
 
i think there is a error while we are inputting the name of the acc. holder
u should flash ur memory before u go for taking the input...check this out..
hav a gud day..

kpsg25690 30Aug2009 08:34

Re: Maintain bank record.
 
Thank you for pointing out the error.
i completely forgot to check that out.
will use your advice but i never really understood what using namespace std was used for.

SaswatPadhi 30Aug2009 09:06

Re: Maintain bank record.
 
Quote:

Originally Posted by c_user (Post 56430)
In line no..42 and 48 u hav forgot the '<' while writting the cout
check out for the syntax...
use
using namespace std;
for less errors..
a very gud programming....
hav a gud day.....

No, not for less errors.
If he is compiling on Turbo C++, he would get even more errors by adding that line.

@ kpsg25690 ::

From your code, I think you use Turbo C++.
If you use Turbo C++, don't add that line.
If you use ANSI C++, you have to make *many* modifications, 'coz your code doesn't conform to it's specifications.

FYI, using namespace std in ANSI C++ allows you to access the members of std namespace directly. It is required because in ANSI C++ the cout, cin and many such commands are inside the std namespace. So, you can either write std.cout / std.cin every time or, you can simply write using namespace std;

c_user 30Aug2009 16:03

Re: Maintain bank record.
 
yes u are right...saswatpadhi...
i actully hav forgot that....thanx for reminding me again...
hav a gud day....

kpsg25690 22Sep2009 15:24

Re: Maintain bank record.
 
thank you for the suggestions guys..
FYI i use turbo c++,
SaswatPadhi is right if i use using namespace std it will give me more errors.
:happy:

naimish 22Sep2009 15:25

Re: Maintain bank record.
 
Line 18: error: conio.h: No such file or directory
Line 20: error: process.h: No such file or directory
t.cpp: In member function 'void bank::deposit()':
Line 41: error: no match for 'operator<' in 'std::cout < "\012Enter the sum you want to deposit:"'
compilation terminated due to -Wfatal-errors.

SaswatPadhi 22Sep2009 18:34

Re: Maintain bank record.
 
Quote:

Originally Posted by naimish (Post 57789)
Line 18: error: conio.h: No such file or directory
Line 20: error: process.h: No such file or directory
t.cpp: In member function 'void bank::deposit()':
Line 41: error: no match for 'operator<' in 'std::cout < "\012Enter the sum you want to deposit:"'
compilation terminated due to -Wfatal-errors.

Bro, you are compiling it in ANSI C++ compiler.

The program is targeted for Turbo C++.


All times are GMT +5.5. The time now is 21:46.