c++个人财务管理系统

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

个人财务管理系统//mynumber.h#includeiostream#includefstream#includecstring#includestring#includeiomanipusingnamespacestd;structrecord{stringtime;stringoperate;intmoney;};structcode{stringpassword;stringacnumber;stringperson1;stringperson2;};constrecordmark={notime\n,no\n,0};classaccount{public:structrecordA;structcodeB;intcheckacnumber();intcheckpassword();voidoldrecord(constchar*filetxt);voidinquire(constchar*filetxt);voiddel(constchar*filetxt);voidincrease(constchar*filetxt);voidCreateTxt(constchar*filetxt);voidprintall(constchar*filetxt);voidprintincome(constchar*filetxt);voidprintpay(constchar*filetxt);voidModifynumber();voidCreateDat();voidInitial(constchar*filetxt);intendmark(recordA);intfindback();voidrecyclebin(constchar*filetxt);};//main.cpp#includemynumber.hconstchar*file=E:\\RecordFile.txt;intmain(){cout欢迎使用个人财务管理系统\n;cout------------------------------------------\n;cout||\n;cout|1.登陆|\n;cout|2.注册|\n;cout||\n;cout------------------------------------------\n;intn,k,t;cinn;accountX;if(n==2){X.CreateDat();n=1;}if(n==1){k=X.checkacnumber();if(k==0)exit(0);else{t=X.checkpassword();if(t==0)exit(0);elsewhile(1){cout-----------请选择您要进行的操作-----------\n;cout||\n;cout|0.退出系统|\n;cout|1.查找记录|\n;cout|2.增加记录|\n;cout|3.删除记录|\n;cout|4.输出所有记录|\n;cout|5.输出所有收入记录|\n;cout|6.输出所有支出记录|\n;cout|7.修改密码|\n;cout|8.初始化记录|\n;cout|9.回收站|\n;charchoice;cinchoice;switch(choice){case'0':cout感谢您使用本系统!\n;exit(0);case'1':X.inquire(file);break;case'2':X.increase(file);break;case'3':X.del(file);break;case'4':X.printall(file);break;case'5':X.printincome(file);break;case'6':X.printpay(file);break;case'7':X.Modifynumber();break;case'8':X.Initial(file);break;case'9':X.recyclebin(file);break;}coutendlendl;cout----------------------------------------\n;cin.get();}}}}//check-acnumber.cpp#includemynumber.hintaccount::checkacnumber(){stringa;intj=3;ifstreamfdat(E:\\accountFile.dat,ios::in);cout请输入您的账号:;while(j--){cina;fdat.seekg(0,ios::beg);fdat.read((char*)&B,sizeof(code));if(a==B.acnumber){fdat.close();return1;}elsecout此账号不存在,请重新输入!\n;}cout\n您的账号已输错三次!请退出系统!\n;fdat.close();return0;}//check-password.cpp#includemynumber.hintaccount::checkpassword(){ifstreamfdat(E:\\accountFile.dat,ios::in);strings;intj=3,x;cout请输入密码:;while(j--){cins;fdat.seekg(0,ios::beg);fdat.read((char*)&B,sizeof(code));if(s==B.password){fdat.close();return1;}elsecout密码错误,请重新输入!\n;}cout\n您输入的密码已错误三次,请问想找回密码吗?(Y/N)\n;charanswer;cinanswer;if(answer=='Y'||answer=='y'){x=account::findback();if(x==1)return1;elsereturn0;}else{cout感谢您使用本系统,再见!\n;return0;}}//CreateDat.cpp#includemynumber.hvoidaccount::CreateDat(){codeB;stringa,b;account::oldrecord(E:\\RecordFile.txt);fstreamtemp(E:\\lalala.txt,ios::out|ios::binary);fstreamrub(E:\\RecycleBin.txt,ios::out|ios::binary);temp.seekp(0,ios::beg);temp.write((char*)&mark,sizeof(record));rub.seekp(0,ios::beg);rub.write((char*)&mark,sizeof(record));while(1){cout请输入您要注册的账号:;cinB.acnumber;coutendl;cout请输入您的密码:;cinB.password;coutendl;cout请重新输入账号:;cinb;coutendl;if(b==B.acnumber){cout请重新输入密码:;cina;coutendl;if(a==B.password){cout为了便于验证身份,请您填写以下信息作为验证方式\n;cout自己身高多少:;cinB.person1;cout自己颜值多高:;cinB.person2;cout(自己身高多少:B.person1)(自己颜值多高:B.person2)\n;cout以上将成为您找回密码的个人验证信息,请务必牢记!\n;fstreamfdat(E:\\accountFile.dat,ios::out|ios::binary);fdat.write((char*)&B,sizeof(code));fdat.close();cout\n请重新登陆\n;cout\n_______________________________________\n;break;}}}}//delete.cpp#includemynumber.hvoidaccount::del(constchar*filetxt){fstreamfdat(filetxt,ios::in|ios::out|ios::binary);fstreamftxt(E:\\lalala.txt,ios::in|ios::out|ios::binary);fstreamrub(E:\\RecycleBin.txt,ios::in|ios::out|ios::binary);while(1){stringE;intn=0;charanswer;cout请输入您要删除的日期:;cinE;fdat.seekg(0,ios::beg);do{fdat.read((char*)&A,sizeof(record));if(E==A.time){n++;cout(A.time,A.operate,A.money)endl;}}while(!endmark(A));if(n==0){cout没有该日期的记录!\n您还要继续删除记录吗?(Y/N)\n;cinanswer;if(answer=='Y'||answer=='y'){coutendl;continue;}else{fdat.close();ftxt.close();rub.close();break;}}else{cout是否确定要删除以上日期记录?(Y/N)\n;cinanswer;if(answer=='Y'||answer=='y'){fdat.seekg(0,ios::beg);ftxt.seekp(0,ios::beg);rub.seekg(0,ios::beg);do{rub.read((char*)&A,sizeof(record));}while(!endmark(A));rub.seekp(-long(sizeof(record)),ios::cur);do{fdat.read((char*)&A,sizeof(record));if(A.time!=E&&!endmark(A)){ftxt.write((char*)&A,sizeof(record));}if(A.time==E&&!endmark(A)){rub.write((char*)&A,sizeof(record));}}while(!endmark(A));ftxt.write((char*)&mark,sizeof(record));rub.write((char*)&mark,sizeof(record));fdat.seekp(0,ios::beg);ftxt.seekg(0,ios::beg);do{ftxt.read((char*)&A,sizeof(record));if(!endmark(A))fdat.write((char*)&A,sizeof(record));}while(!endmark(A));fdat.write((char*)&mark,sizeof(record));cout成功删除记录!\n;cout您是否还要继续删除日期记录?(Y/N)\n;cinanswer;if(answer=='Y'||answer=='y'){coutendl;continue;}else{fdat.close();ftxt.close();rub.close();break;}}elsecout取消操作!\n;}}}//findback.cpp#includem

1 / 15
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功