中易网

求。c++编写家庭财务管理系统。。

答案:2  悬赏:80  
解决时间 2021-02-02 09:18
做课程设计用的,帮下忙。。

亲,用类实现奥。。我实在是没有财富值。谢谢了。。急求。。
最佳答案
c++编写家庭财务管理系统
|一| 可代做 +Q
全部回答

#include <iostream> #include <iomanip> #include <fstream> #include <cstring> #include "hsk2007.h" void main() { int a,b,c; //时间项 float in,out,all; //收入、支出、共计 char x,y,z; //功能选择字符 struct record r; //日记录单元 do { cout<<"\n\n\t____________________________________________________\n\n\n\t 家庭财务管理2007\n\n\t____________________________________________________\n\n\t <b>新建记录 <l>查询记录 <q>退出\n\n\t请选择(输入选项前对应的字母):"; cin>>x; strupr(&x); if(x=='b') { cout<<"\n\t新建记录->\n\t请输入:\n\t新记录的日期(年 月 日):"; //新建记录 cin>>a>>b>>c; if(a>=1980&&a<=2100&&b>=1&&b<=12&&c>=1&&c<=31) { cout<<"\t新记录当日的收入:"; cin>>in; cout<<"\t新记录当日的支出:"; cin>>out; w(a,b,c,in,out); cout<<"\t新记录已建立!\n"; } else cout<<"\t输入有误,请重新输入!"; } if(x=='l') do { cout<<"\n\n\t查询记录->\n\t查询方式: <y>年 <s>季度 <m>月 <d>日 <q>退出\n\t请选择(输入选项前对应的字母):"; //查询记录 cin>>y; strupr(&y); if(y=='y') { cout<<"\n\t查询记录->按年查询->\n\t请输入所查询的年份:"; //按年查询 cin>>a; if(a>=1980&&a<=2100) { do { cout<<"\t是否查询日记录(y/n):"; cin>>z; strupr(&z); if(z=='y'||z=='n') year(a,z); else cout<<"\t输入有误,请重新选择!\n"; } while(z!='y'&&z!='n'); } else cout<<"\t输入有误,请重新输入!"; } if(y=='s') { cout<<"\n\t查询记录->按季度查询->\n\t请输入所查询的年份、季度:"; //按季度查询 cin>>a>>b; if(a>=1980&&a<=2100&&b>=1&&b<=4) { do { cout<<"\t是否查询日记录(y/n):"; cin>>z; strupr(&z); if(z=='y'||z=='n') season(a,b,z); else cout<<"\t输入有误,请重新选择!\n"; } while(z!='y'&&z!='n'); } else cout<<"\t输入有误,请重新输入!"; } if(y=='m') { cout<<"\n\t查询记录->按月查询->\n\t请输入所查询的年份、月份:"; //按月查询 cin>>a>>b; if(a>=1980&&a<=2100&&b>=1&&b<=12) { do { cout<<"\t是否查询日记录(y/n):"; cin>>z; strupr(&z); if(z=='y'||z=='n') month(a,b,z,&in,&out); else cout<<"\t输入有误,请重新选择!\n"; } while(z!='y'&&z!='n'); } else cout<<"\t输入有误,请重新输入!"; } if(y=='d') { cout<<"\n\t查询记录->按日查询->\n\t请输入所查询的日期:"; //按日查询 cin>>a>>b>>c; if(a>=1980&&a<=2100&&b>=1&&b<=12) { day(a,b,c,&r); all=r.w[0]-r.w[1]; cout<<"\t "<<r.t[0]<<"年"<<r.t[1]<<"月"<<r.t[2]<<"日 收入:"<<r.w[0]<<" 支出:"<<r.w[1]<<" 共计:"<<all<<endl; } else cout<<"\t输入有误,请重新输入!"; } if(y!='y'&&y!='s'&&y!='m'&&y!='d'&&y!='q') cout<<"\t输入有误,请重新选择!"; } while(y!='q'); if(x!='b'&&x!='l'&&x!='q') cout<<"\t输入有误,请重新选择!"; } while(x!='q'); }

using namespace std; //命名空间 struct record //记录 { int t[3]; //年、月、日 float w[2]; }; //收入、支出

void w(int year,int month,int day,float in=0.0,float out=0.0) //写日记录 { struct record r; ofstream file; r.t[0]=year; r.t[1]=month; r.t[2]=day; r.w[0]=in; r.w[1]=out; file.open("家庭收支记录.txt",ios_base::app); file.write((char *)&r,sizeof(struct record)); file.close(); }

void day(int y,int m,int d,struct record *p) //读日记录 { ifstream file; file.open("家庭收支记录.txt",ios_base::in); file.seekg(0,ios::beg); do file.read((char *)p,sizeof(struct record)); while(!file.eof()&&(p->t[0]<y||p->t[0]==y&&p->t[1]<m||p->t[0]==y&&p->t[1]==m&&p->t[2]<d)); if(p->t[0]!=y||p->t[1]!=m||p->t[2]!=d) { p->t[0]=y; p->t[1]=m; p->t[2]=d; p->w[0]=0.0; p->w[1]=0.0; } file.close(); }

void month(int y,int m,char z,float *in,float *out) //读月记录 { int d; float min=0.0,mout=0.0,mall; struct record r; for(d=1;d<=31;d++) { day(y,m,d,&r); if(r.w[0]!=0.0||r.w[1]!=0.0) { min=min+r.w[0]; mout=mout+r.w[1]; if(z=='y') cout<<"\t "<<r.t[0]<<"-"<<r.t[1]<<"-"<<r.t[2]<<" 收入:"<<r.w[0]<<" 支出:"<<r.w[1]<<endl; } } mall=min-mout; *in=min; *out=mout; cout<<"\t "<<y<<"年"<<setw(2)<<m<<"月 收入:"<<min<<" 支出:"<<mout<<" 共计:"<<mall<<endl; }

void season(int y,int s,char z) //读季度记录 { int m; float sin=0.0,sout=0.0,sall,in,out; for(m=3*s-2;m<=3*s;m++) { month(y,m,z,&in,&out); sin=sin+in; sout=sout+out; } sall=sin-sout; cout<<"\t "<<y<<"年"<<s<<"季度 收入:"<<sin<<" 支出:"<<sout<<" 共计:"<<sall<<endl; }

void year(int y,char z) //读年记录 { int m; float yin=0.0,yout=0.0,yall,in,out; for(m=1;m<=12;m++) { month(y,m,z,&in,&out); yin=yin+in; yout=yout+out; } yall=yin-yout; cout<<"\t "<<y<<"年 收入:"<<yin<<" 支出:"<<yout<<" 共计:"<<yall<<endl; }

我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
如何克隆人
佛山禅城那个影院有情侣包间,大概多少钱??
QQ王朝有多少个紫将和橙将
上联:黄翔上海拉翔黄海上 求下联
和中村新街在哪里啊,我有事要去这个地方
穿越火线画面是白色是怎么回事
虚拟城市金钱修改器
大冲坑地址在什么地方,想过去办事
福建13年考生 想学编导的话 文化分和专业分要
女人分手会删除关于前任微信朋友圈的一切心情
诺基亚520手机恢复出厂设置要多久?
翻建油漆地址在什么地方,想过去办事
乱世佳人 演员名称 要中英~~急急急
跪求兄弟战争粉红激情的中文攻略,实在太需要
AIX上面C++编译报错:0711-224 duplicate
推荐资讯
机械迷城煮皮管的锅怎么不开啊
果麦(德化新街店)地址在哪,我要去那里办事
渑池县社会福利中心这个地址在什么地方,我要
无线AP ip是192.168.2.66怎么在电脑上设置才
南瓜侧蔓剪掉还会长出来吗
长春那里有单人间的公寓~~~
由数1.4.9.16.25组成的集合
长虹Q3T怎么连接电脑主机,看视频
有哪些可以放进龟缸里的水植物,水里只有些雨
长发房产我想知道这个在什么地方
扩展容量32GB,是什么意思呢?是指手机可以扩
苏州哪些民办学校好,我报了这些:中加枫华、
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?