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: [LEFT]#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(); } [/LEFT]
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.....
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..
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.
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;
yes u are right...saswatpadhi... i actully hav forgot that....thanx for reminding me again... hav a gud day....
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:
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.