| | |
how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
#include<fstream.h> #include<stdio.h> #include<conio.h> #include<string.h> #include<iostream.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> void deposit(void); void addrecord(); void delrecord(); void modrecord(); void disprecord(); void dispall(); void withdraw(); float w,z; class account { int accountno,cls; char name[30],type; float deposit,withdraw; public: account() { deposit=withdraw=0; } int giveaccountno() { return accountno; } void getdata(int mrno) { accountno=mrno+1; cout<<"\t\t\tACCOUNT NUMBER:"; cout<<accountno<<" \n"; cout<<"\t\t\tENTER YOUR NAME:"; gets(name); cout<<" "; cout<<"\t\t\tENTER TYPE OF ACCOUNT SAVING(s)/CURRENT(c):"; cin>>type; cout<<" "; cout<<"\t\t\tENTER INITIAL AMOUNT:Php.";cin>>deposit; cout<<" "; clrscr(); } void withdrawal(int m) { cout<<"\n\n\n\n\n\n\n\n\n\t\tAMOUNT BEFORE WITHDRAWING:Php."<<deposit<<""; deposit=deposit-m; cout<<"\n\n\t\tAMOUNT AFTER WITHDRAWING:Php."<<deposit; } void deposital(int m) { cout<<"\n\n\n\n\n\n\n\n\n\t\tAMOUNT BEFORE DEPOSIT:Php."<<deposit<<""; deposit=deposit+m; cout<<"\n\n\t\tAMOUNT AFTER DEPOSIT :Php."<<deposit; } void dispdata() { int scrnt=0; if(scrnt==1) { clrscr(); cout<<"\t\t\tDISPLAY ALL MENU "; scrnt=0; } cout<<"\n\t\t\tACCOUNT NUMBER:"; cout<<accountno; cout<<"\n\t\t\tNAME OF DEPOSITOR:"; cout<<name; cout<<"\n\t\t\tTYPE OF ACCOUNT SAVING(s)/CURRENT(c):"; cout<<type; cout<<"\n\t\t\tBALANCE :Php."; cout<<deposit; scrnt++; } }; void main() { int menuch; do { clrscr(); textcolor(14); textbackground(1); cout<<"\n\t\t\tKIKIMUT BANKING SYSTEM..."; cout<<"\n\n\n\n\n\n\n\n\t\t\tMAIN MENU\n"; cout<<"\n\t\t\t1.NEW ACCOUNT"; cout<<"\n\t\t\t2.CLOSE AN ACCOUNT"; cout<<"\n\t\t\t3.MODIFY AN ACCOUNT"; cout<<"\n\t\t\t4.DISPLAY AN ACCOUNT"; cout<<"\n\t\t\t5.DISPLAY ALL RECORDS"; cout<<"\n\t\t\t6.WITHDRAW AMOUNT"; cout<<"\n\t\t\t7.DEPOSIT AMOUNT"; cout<<"\n\t\t\t8.EXIT"; cout<<"\n\t\t\tENTER YOUR CHOICE:"; cin>>menuch; switch(menuch) { case 1:addrecord();break; case 2:delrecord();break; case 3:modrecord();break; case 4:disprecord();break; case 5:dispall();break; case 6:withdraw();break; case 7:deposit();break; } } while(menuch!=8); } void addrecord() { account obj_1,obj_2; fstream fout; fout.open("banking.txt",ios::in|ios::binary); if(!fout) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR";getch();return;} int recsize=sizeof(account); fout.seekg(0,ios::end); fout.seekg(-1*recsize,ios::cur); fout.read((char*)&obj_1,recsize); int mrno=obj_1.giveaccountno(); fout.close(); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\t\tADD MENU\n"; obj_2.getdata(mrno); fout.open("banking.txt",ios::app|ios::binary); if(!fout) { cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR";getch();return;} fout.write((char*)&obj_2,recsize); cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tRECORD ADDED TO DATABASE\n"<<"\n\t\t\tPress any key to continue... "; getch(); fout.close(); } void dispall() { account obj_3; fstream fout; int recsize=sizeof(account); int countrec=0; clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tDISPLAY ALL MENU\n\n "; fout.open("banking.txt",ios::in); if(!fout) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR ";getch();return;} while(fout.read((char*)&obj_3,recsize)) { obj_3.dispdata(); countrec++; cout<<"\n\n\t\t\tPRESS ANY KEY FOR NEXT....\n\n"; getch(); } clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tEND OF FILE.TOTAL NUMBER OF RECORDS..."<<countrec; cout<<"\n\n\t\t\tPress any key to continue......"; getch(); fout.close();} void disprecord() { account obj_4; fstream fout; int mrno,flag=0; int recsize=sizeof(account); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tDISPLAY A RECORD MENU\n"; fout.open("banking.txt",ios::in); if(!fout) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR ";getch();return;} cout<<"\n\t\t\tENTER THE ACCOUNT NUMBER:";cin>>mrno; while(fout.read((char*)&obj_4,recsize)) { if (obj_4.giveaccountno()==mrno) { obj_4.dispdata(); cout<<"\n\n\t\t\tPress any key to continue....."; flag=1;break; } } if(flag==0) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tNO SUCH ACCOUNT EXIST"; cout<<"\n\t\t\tPress any key......"; } getch(); fout.close(); } void delrecord() { account obj_5; fstream fout,temp; int mrno,flag; int recsize=sizeof(account); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tCLOSE ACCOUNT MENU\n"; fout.open("banking.txt",ios::in); if(!fout) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\t\tFILE OPEN ERROR"; getch(); return; } temp.open("temp.txt",ios::app|ios::binary); if(!temp) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t\tFILE OPEN ERROR"; getch(); return; } cout<<"\n\t\t\tENTER THE ACCOUNT NUMBER:"; cin>>mrno; clrscr(); while(fout.read((char*)&obj_5,recsize)) { if(obj_5.giveaccountno()==mrno) { obj_5.dispdata(); char confirm; clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tARE YOU SURE TO DELETE IT(Y/N)..";cin>>confirm; if(confirm=='Y'||confirm=='y') { fout.read((char*)&obj_5,recsize); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tRECORD DELETED FROM DATABASE\n"; cout<<"\n\t\t\tpress any key to continue...."; flag=1; if(!fout) break; } flag=1; } temp.write((char*)&obj_5,recsize);} fout.close(); temp.close(); remove("banking.txt"); rename("temp.txt","banking.txt"); if(flag==0) { cout<<"NO SUCH ACCOUNT EXIST\n"; cout<<"Press any key to continue.....\n"; } getch(); } void modrecord() { account obj_6; fstream fout; int mrno,flag=0; int recsize=sizeof(account); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tMODIFY RECORD MENU\n"; fout.open("banking.txt",ios::in|ios::out|ios::binary); if(!fout) { cout<<"FILE OPEN ERROR"; getch(); return; } fout.seekg(ios::beg); cout<<"\n\t\t\tENTER RECORD NUMBER:"; cin>>mrno; while(fout.read((char*)&obj_6,recsize)) { if(obj_6.giveaccountno()==mrno) { clrscr(); cout<<"\n\n\t\t\tOLD DATA\n"; obj_6.dispdata(); int tmprno=obj_6.giveaccountno()-1; account obj_7; cout<<"\n\n\t\t\tENTER NEW DATA\n\n"; obj_7.getdata(tmprno); char confirm; cout<<"\n\n\n\n\n\n\n\n\n\t\t\tARE YOU SURE(Y/N) "; cin>>confirm; if(confirm=='Y'||confirm=='y') { fout.seekg(-1*recsize,ios::cur); fout.write((char*)&obj_7,recsize); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tRECORD MODIFIED"; cout<<"\n\t\t\tPress any key to continue....."; flag=1; } } if(flag==0) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tNO SUCH RECORD EXIST\n"; cout<<"\t\t\tPress any key to continue.....\n"; } } fout.close(); getch(); } void withdraw() { account obj_9; fstream fout; int mrno=0; int recsize=sizeof(account); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tWITHDRAWAL MENU"; fout.open("banking.txt",ios::in|ios::out|ios::binary); if(!fout) { cout<<"FILE OPEN ERROR";getch();return;} fout.seekg(ios::beg); cout<<"\n\n\t\t\tENTER ACCOUNT NUMBER:"; cin>>mrno; while(fout.read((char*)&obj_9,recsize)) { if(obj_9.giveaccountno()==mrno) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\tENTER THE AMOUNT TO BE WITHDRAWN:Php."; cin>>w; clrscr(); obj_9.withdrawal(w); fout.seekg(-1*recsize,ios::cur); fout.write((char*)&obj_9,recsize); } } fout.close(); getch(); } void deposit(void) { account obj_10; fstream fout; int mrno=0; int recsize=sizeof(account); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\t\tDEPOSITAL MENU\n"; fout.open("banking.txt",ios::in|ios::out|ios::binary); if(!fout) { cout<<"FILE OPEN ERROR";getch();return;} fout.seekg(ios::beg); cout<<"\n\t\t\tENTER ACCOUNT NUMBER:"; cin>>mrno; while(fout.read((char*)&obj_10,recsize)) { if(obj_10.giveaccountno()==mrno) { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\t\tENTER THE AMOUNT TO BE DEPOSITED:Php."; cin>>w; clrscr(); obj_10.deposital(w); fout.seekg(-1*recsize,ios::cur); fout.write((char*)&obj_10,recsize); } } fout.close(); getch(); }
Last edited by jayli27; Mar 6th, 2009 at 9:33 am. Reason: add code tags
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#3 Mar 6th, 2009
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#4 Mar 6th, 2009
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#5 Mar 6th, 2009
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#6 Mar 6th, 2009
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#7 Mar 6th, 2009
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#8 Mar 6th, 2009
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#9 Mar 6th, 2009
Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.
0
#10 Mar 6th, 2009
![]() |
Other Threads in the C++ Forum
- Previous Thread: SSE alligned allocation inside struct
- Next Thread: slotmachine reel spin simulation
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






