家庭财务管理设计与实现
来源:互联网 发布:linux date修改时间 编辑:程序博客网 时间:2024/04/29 10:07
家庭财务管理设计与实现
实现家庭的各种账单(水/电/煤气费,宽带/电话费等)的管理功能,可以对各类账单及用户信息进行登记、修改、删除等。
2、 程序的基本功能:
1. 增加、修改、删除一个用户资料。
2. 增加、修改、删除一种账单。
3. 按条件查询显示用户资料(条件有姓名等)。
4. 按条件显示各类账单信息(条件有帐单类型、用户名等)。
5. 查找指定金额范围的指定类型账单。
6. 能按月份和年份统计家庭各类帐单信息和总和。
源代码:
#include <iostream>#include <string.h>#include <iomanip>#include <time.h>#include <fstream>#include <cctype>#include <windows.h>using namespace std;class Time //创建时间类,用于后面继承 { public: void GetTime(int n,int m,int d) {year=n,month=m;day=d;} void CheckTime(); //查询输入的时间错误检查 private:int year,month,day;}TT; typedef class CFinance:public Time //定义一个Infor类型 ,继承时间类并增加姓名等... { public: CFinance(const char *_Name,const char *_CheckType) //因为是指针型数组用拷贝构造函数 { strcpy(Name,_Name); strcpy(CheckType,_CheckType); } int year,month,day; double Income,Output; char Name[10],CheckType[10]; //定义姓名 和 账单类型 CFinance *next;}Infor;void Time::CheckTime() //时间错误检查{ if(month>12 ||month<1) { MessageBox(NULL,"月份输入错误","错误!",MB_OK); //windows的函数,弹出错误窗口。 exit(0); } else { if(month==1||month==3 ||month==5||month==7||month==8||month==10||month==12) { if(day>31 || day<1) { MessageBox(NULL,"日期输入错误","错误!",MB_OK); exit(0); } } else { if(month==4||month==6 ||month==9||month==11) if(day<1||day>30) { MessageBox(NULL,"日期输入错误","错误!",MB_OK); exit(0); } } } if(month==2) if(day>29||day<1) { MessageBox(NULL,"日期输入错误","错误!",MB_OK); exit(0); }}int menu_select();void SearchIncomeInfor(Infor *head); //查询的五个函数 void SearchOutputInfor(Infor *head);void SearchDateInfor(Infor *head);void SearchNameInfor(Infor *head);void SearchCheckTypeInfor(Infor *head);void CalculateMonthInfor(Infor *head); //统计的三个函数 void CalculateYearInfor (Infor *head);void CalculateDayInfor (Infor *head);void AlterNameInfor(Infor *head); //修改的两个函数 void AlterCheckTypeInfor(Infor *head);void DeleteNameInfor(Infor *head); //删除的两个函数 void DeleteCheckTypeInfor(Infor *head);Infor *Inforinitlist() //创建信息空链表{ Infor *head; head=(Infor*)malloc(sizeof(Infor)); head->next =NULL; return head;} int menu_select() //主菜单 { const char *m[8]={"1.录入详细财务信息","2.浏览全部财务信息","3.查询财务信息(按条件)","4.统计财务信息(按条件)","5.修改财务信息","6.删除财务系统","7.保存财务信息","8.退出财务系统"}; char *c; c=new char[50]; while(c[0]<'1'||c[0]>'8'||c[1]) { system("cls"); cout<<endl<<"---------家庭财务管理系统总菜单----------"<<endl; for(int i=0;i<8;i++) cout<<m[i]<<endl; cout<<"Choose:"<<endl; cin>>c; } return(c[0]-'0');}void InputFinanceInfor(Infor *head) // 1、输入财务信息{ system("cls"); cout<<endl<<"------------输入财务信息------------"<<endl; Infor *p1,*p2,*p3; p3=head; if(NULL!=p3->next) { p3=p3->next; } p2=p3; char input;while(toupper(input)!='N'){ p1=(Infor*)malloc(sizeof(Infor)); cout<<"年份[int]: "; cin>>p1->year; cout<<"月份[int]: "; cin>>p1->month; cout<<"日期[int]: "; cin>>p1->day; cout<<"用户姓名[char]: "; cin>>p1->Name; cout<<"账单类型(例:电费)[char]: "; cin>>p1->CheckType; cout<<"收入[double]: "; cin>>p1->Income; cout<<"支出[double]: "; cin>>p1->Output; p2->next=p1; p2=p1; cout<<endl<<"*********按 N 结束录入,按其它键继续输入:"; cin>>input;}p2->next=NULL;}void ListFinanceInfor(Infor *head) // 2、浏览财务信息{ Infor *p; p=head->next; if(p!=NULL) { system("cls"); cout<<endl<<"-----------浏览全部财务信息-----------"<<endl; while(p!=NULL) {cout<<"======================================"<<endl;cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"用户姓名: "<<p->Name<<endl;cout<<"账单类型: "<<p->CheckType<<endl;cout<<"收入情况:"<<p->Income<<endl;cout<<"支出情况:"<<p->Output<<endl;cout<<"======================================"<<endl;p=p->next;} } else { cout<<endl<<"财务信息为空!"<<endl; }}void SearchMenu(Infor *head)// 3、查询总菜单{Infor *p;p=head->next;int Ch;system("cls");cout<<endl<<"-------------财务查询-------------"<<endl;cout<<"1.按支出查询"<<endl;cout<<"2.按收入查询"<<endl;cout<<"3.按日期查询"<<endl;cout<<"4.按用户姓名查询"<<endl;cout<<"5.按账单类型查询"<<endl;cout<<"6.返回上层"<<endl;cout<<"---------------------------------"<<endl;cout<<"Choose:";cin>>Ch;switch (Ch){case 1:SearchOutputInfor(p); break;case 2: SearchIncomeInfor(p); break;case 3: SearchDateInfor(p); break; case 4: SearchNameInfor(p); break;case 5: SearchCheckTypeInfor(p); break;case 6: return;default: break;}}void CalculateInfor(Infor *head) // 4、统计的总菜单 {Infor *p;p=head->next;int Ch;system("cls");cout<<endl<<"-----------财务统计-----------"<<endl<<endl;cout<<"1.按年统计"<<endl;cout<<"2.按月统计"<<endl;cout<<"3.按日统计"<<endl;cout<<"4.返回上层"<<endl;cout<<"-------------------------------"<<endl<<endl;cout<<"Choose:";cin>>Ch;switch (Ch){ case 1:CalculateYearInfor(p); break; case 2:CalculateMonthInfor(p);break; case 3:CalculateDayInfor(p);break; case 4: return; default: break;}}void AlterInfor(Infor *head) // 5、修改的总菜单 { system("cls"); int ch; Infor *p; p=head;cout<<endl<<"-------------修改财务信息-------------"<<endl;cout<<"1.按用户姓名修改"<<endl;cout<<"2.按账单类型修改"<<endl;cout<<"3.返回上层"<<endl;cout<<"-----------------------------------"<<endl;cout<<"Choose:";cin>>ch;switch (ch){case 1:AlterNameInfor(p); break;case 2: AlterCheckTypeInfor(p); break;case 3: return;default: break;}}void DeleteInfor(Infor *head) // 6、删除的总菜单 {system("cls"); int ch; Infor *p; p=head;cout<<endl<<"-------------删除财务信息-------------"<<endl;cout<<"1.按用户姓名删除"<<endl;cout<<"2.按账单类型删除"<<endl;cout<<"3.返回上层"<<endl;cout<<"-----------------------------------"<<endl;cout<<"Choose:";cin>>ch;switch (ch){case 1:DeleteNameInfor(p); break;case 2: DeleteCheckTypeInfor(p); break;case 3: return;default: break;}} void SaveToFile(Infor *head) //7、写入文件 { fstream FInfor("家庭财务管理.dat",ios::out | ios::binary); if(!FInfor) { cout<<"文件打开失败!"; } Infor *p; p=head->next; while(p!=NULL) { FInfor<<"\t年份:"<<p->year<<endl; FInfor<<"\t月份:"<<p->month<<endl; FInfor<<"\t日期:"<<p->day<<endl; FInfor<<"\t收入情况:"<<p->Income<<endl; FInfor<<"\t支出情况:"<<p->Output<<endl; FInfor<<"\t用户姓名:"<<p->Name<<endl; FInfor<<"\t账单类型:"<<p->CheckType<<endl; FInfor<<"\t\t\t\t\t\t"; p=p->next; } FInfor.close(); system("C:/WINDOWS/NOTEPAD 家庭财务管理.dat");}void SearchOutputInfor(Infor *head) // 按支出查询 {Infor *p;p=head;system("cls");cout<<endl<<"-------------按支出查询-------------"<<endl;while(p!=NULL){if(0!=p->Output){cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"用户姓名: "<<p->Name<<endl;cout<<"账单类型: "<<p->CheckType<<endl;cout<<"收入情况:"<<p->Income<<endl;cout<<"支出情况:"<<p->Output<<endl;cout<<"-------------------------------"<<endl;}p=p->next;}}void SearchIncomeInfor(Infor *head) // 按收入查询 {Infor *p;p=head;system("cls");cout<<endl<<"-----------按收入查询-----------"<<endl;while(p!=NULL){if(0!=p->Output){cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"用户姓名: "<<p->Name<<endl;cout<<"账单类型: "<<p->CheckType<<endl;cout<<"收入情况:"<<p->Income<<endl;cout<<"支出情况:"<<p->Output<<endl;cout<<"---------------------------------"<<endl;}p=p->next;}}void SearchDateInfor(Infor *head) // 按日期查询 {int x,y,z;Infor *p;p=head;cout<<"请输入日期:"<<endl;cin>>x>>y>>z;TT.GetTime(x,y,z);TT.CheckTime();system("cls");cout<<endl<<"-----------按日期查询-----------"<<endl;while(x!=p->year||y!=p->month||z!=p->day){if(p->next ==NULL){ cout<<"未找到记录!"<<endl; cout<<"---------------------------------"<<endl; break; } p=p->next;}cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"用户姓名: "<<p->Name<<endl;cout<<"账单类型: "<<p->CheckType<<endl;cout<<"收入情况:"<<p->Income<<endl;cout<<"支出情况:"<<p->Output<<endl;cout<<"---------------------------------"<<endl;}void SearchNameInfor(Infor *head) // 按姓名查询 {int m;char a[20]={"\0"}; Infor *p;p=head;cout<<"请输入用户姓名:"<<endl;cin>>a;system("cls");cout<<endl<<"-----------按用户姓名查询-----------"<<endl;while(p!=NULL){if((m=strcmp(a,p->Name))==0){cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"用户姓名: "<<p->Name<<endl;cout<<"账单类型: "<<p->CheckType<<endl;cout<<"收入情况:"<<p->Income<<endl;cout<<"支出情况:"<<p->Output<<endl;cout<<"---------------------------------"<<endl;}p=p->next;}}void SearchCheckTypeInfor(Infor *head) // 按账单类型查询 {int m;char a[20]={"\0"}; Infor *p;p=head;cout<<"请输入账单类型:"<<endl;cin>>a;system("cls");cout<<endl<<"-----------按账单类型查询-----------"<<endl;while(p!=NULL){if((m=strcmp(a,p->CheckType))==0){cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"用户姓名: "<<p->Name<<endl;cout<<"账单类型: "<<p->CheckType<<endl;cout<<"收入情况:"<<p->Income<<endl;cout<<"支出情况:"<<p->Output<<endl;cout<<"---------------------------------"<<endl;}p=p->next;}}void CalculateYearInfor (Infor *head) //按年统计{int x,outsum=0,insum=0;Infor *p;p=head;system("cls");cout<<endl<<"-----------按年统计-----------"<<endl;cout<<"输入年份:"<<endl;cin>>x;while(p!=NULL){if(x==p->year){ cout<<setw(8)<<"年:"<<p->year<<endl; cout<<setw(8)<<"月:"<<p->month<<endl; cout<<setw(8)<<"日:"<<p->day<<endl; cout<<setw(8)<<"支出:"<<p->Output<<endl; outsum=outsum+p->Output; cout<<setw(8)<<"收入:"<<p->Income<<endl; insum=insum+p->Income; cout<<"---------------------------------"<<endl;} p=p->next;}cout<<setw(8)<<"总收入:"<<insum<<endl;cout<<setw(8)<<"总支出:"<<outsum<<endl;}void CalculateMonthInfor(Infor *head) //按月统计{int x,y,outsum=0,insum=0;Infor *p;p=head;system("cls");cout<<endl<<"-----------按月统计-----------"<<endl;cout<<"输入年份、月份:"<<endl;cin>>x>>y;while(p!=NULL){if(x==p->year&&y==p->month){ cout<<setw(8)<<"年:"<<p->year<<endl; cout<<setw(8)<<"月:"<<p->month<<endl; cout<<setw(8)<<"日:"<<p->day<<endl; cout<<setw(8)<<"支出:"<<p->Output<<endl; outsum=outsum+p->Output; cout<<setw(8)<<"收入:"<<p->Income<<endl; insum=insum+p->Income; cout<<"---------------------------------"<<endl;}p=p->next;}cout<<setw(8)<<"总收入:"<<insum<<endl;cout<<setw(8)<<"总支出:"<<outsum<<endl;}void CalculateDayInfor (Infor *head) //按日统计{int x,y,z,outsum=0,insum=0;Infor *p;p=head;system("cls");cout<<endl<<"-----------按日统计-----------"<<endl;cout<<"输入年份、月份、日期:"<<endl;cin>>x>>y>>z;while(p!=NULL){if(x==p->year&&y==p->month&&z==p->day){ cout<<setw(8)<<"年:"<<p->year<<endl; cout<<setw(8)<<"月:"<<p->month<<endl; cout<<setw(8)<<"日:"<<p->day<<endl; cout<<setw(8)<<"支出:"<<p->Output<<endl; outsum=outsum+p->Output; cout<<setw(8)<<"收入:"<<p->Income<<endl; insum=insum+p->Income; cout<<"---------------------------------"<<endl;}p=p->next;}cout<<setw(8)<<"总收入:"<<insum<<endl;cout<<setw(8)<<"总支出:"<<outsum<<endl;}void AlterNameInfor(Infor *head) //按姓名修改 {int m;char a[20]={"\0"}; Infor *p;p=head;system("cls");cout<<endl<<"-----------按用户姓名修改-----------"<<endl;cout<<"请输入需要修改账单的姓名:"<<endl;cin>>a;while(p!=NULL){if((m=strcmp(a,p->Name))==0){cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"用户姓名: "<<p->Name<<endl;cout<<"账单类型改为: "<<endl;cin>>p->CheckType;cout<<"收入情况改为:"<<endl;cin>>p->Income;cout<<"支出情况改为:"<<endl;cin>>p->Output;cout<<"---------------------------------"<<endl; }p=p->next;}}void AlterCheckTypeInfor(Infor *head) //按账单类型修改 {int m;char a[20]={"\0"}; Infor *p;p=head;system("cls");cout<<endl<<"-----------按账单类型修改-----------"<<endl;cout<<"请输入需要修改账单的账单类型:"<<endl;cin>>a;while(p!=NULL){if((m=strcmp(a,p->CheckType))==0){cout<<p->year<<" 年"; cout<<p->month<<" 月";cout<<p->day<<" 日"<<endl;cout<<"账单类型: "<<p->CheckType<<endl;cout<<"用户姓名改为: "<<endl;cin>>p->Name;cout<<"收入情况改为:"<<endl;cin>>p->Income;cout<<"支出情况改为:"<<endl;cin>>p->Output;cout<<"---------------------------------"<<endl; }p=p->next;}}void DeleteNameInfor(Infor *head) //按姓名删除 {int m;char a[20]={"\0"}; Infor *p,*q,*r;p=head;q=head; r=head;system("cls");cout<<endl<<"-----------按用户姓名删除-----------"<<endl;cout<<"请输入需要删除账单的姓名:"<<endl;cin>>a;while(p!=NULL){if((m=strcmp(a,p->Name))==0){r=p->next;q->next=r; cout<<"用户姓名为 "<<p->Name; cout<<" 的用户资料已删除成功! "<<endl; cout<<"---------------------------------"<<endl; } q=p; p=p->next;}} void DeleteCheckTypeInfor(Infor *head) //按账单类型删除 {int m;char a[20]={"\0"}; Infor *p,*q,*r;p=head;q=head; r=head;system("cls");cout<<endl<<"-----------按账单类型删除-----------"<<endl;cout<<"请输入需要删除账单的账单类型:"<<endl;cin>>a;while(p!=NULL){if((m=strcmp(a,p->CheckType))==0){r=p->next;q->next=r; cout<<"账单类型为 "<<p->CheckType; cout<<" 的资料已删除成功! "<<endl; cout<<"---------------------------------"<<endl; } q=p; p=p->next;}}int main(){ Infor *X,*head=NULL; X=Inforinitlist(); int choose=0; while(choose!=8) { choose=menu_select(); //每次刷新主界面 switch(choose) { case 1: InputFinanceInfor(X); system("pause"); //该函数作用是保留屏幕,等待用户按任意键,然后返回 break; case 2: ListFinanceInfor(X);system("pause"); break; case 3: SearchMenu(X);system("pause"); break; case 4: CalculateInfor(X);system("pause"); break; case 5: AlterInfor(X);system("pause"); break; case 6: DeleteInfor(X);system("pause"); break;case 7: system("cls"); SaveToFile(X); break;case 8: exit(0); break;default: cout<<"输入错误!请重新输入:"<<endl; } } return 0; }
0 0
- 家庭财务管理设计与实现
- 家庭财务管理小程序
- 家庭财务管理系统 绿色
- 家庭财务管理系统源代码
- 数据结构课程设计【家庭财务管理系统】
- 课程设计——家庭财务管理
- 家庭财务管理系统实战2-easyui界面主框架搭建以及Accordion手风琴菜单实现
- 家庭财务管理系统实战3- 实现列表数据的增删改查功能
- 家庭财务管理系统实战4- mybatis分页查询功能改进实现
- 家庭财务管理系统实战5- 支出信息的增加修改与删除
- 财务管理----记账凭证的输入格式设计与数据库设计
- 记账精灵——家庭财务管理系统
- 家庭财务管理系统实战7-终结,源码
- 1009:财务管理【JAVA实现】
- 财务管理
- 财务管理
- 如何使用W3150A+芯片实现家庭网关系统软硬件设计
- 家庭财务管理系统实战1-SpringMVC3+Spring3+Mybatis3+easyui环境整合搭建
- Java 自动装箱与拆箱(Autoboxing and unboxing)
- linux 写一个服务的启动 关闭 查看状态 脚本 例子:sshd
- solr-单机配置
- 3. Longest Substring Without Repeating Characters
- Java基本数据类型和其包装类
- 家庭财务管理设计与实现
- 设计模式:Decorator(装饰)模式
- java js常用正则表达式和工具函数
- Translucent System Bar 的最佳实践
- Java中private、protected、public和default的区别
- 斐波拉契序列
- 【iOS沉思录】iOS内存管理试题总结与详解
- 增强学习(三)----- MDP的动态规划解法
- Hive编程指南09---调优