个人理财管理系统代码

#include <algorithm>
#include <iostream>
#include <windows.h>//调用
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <time.h>
#include <cctype>
#include <map>
#include <set>  //一大批头文件
using namespace std;

class Time  //时间类
{
//基类的私有成员定义
private:
    int month;
    int day;
    int year;
//基类的公用成员定义
public:
    void GetTime(int y,int m,int d)//此函数用来获取时间的年月日
    {
        year=y;
        month=m;
        day=d;
    }
    void CheckTime();//此函数用来检查时间的年月日
} Time1;//声明一个对象Time1

void Time::CheckTime()  //时间错误检查
{
    //判断输入是否符合要求
    //用if --else 简单语句进行判断
    if(month>12 ||month<1)
    {
        MessageBox(NULL,"月份输入错误","错误!",MB_OK);
        exit(0);
    }
    else
    {
        if(month==1||month==3 ||month==5||month==7||month==8||month==10||month==12)//宋政在此调试,时间2014/11/15,考虑月份不周全,进行完善
        {
            if(day>31 || day<1)
            {
                MessageBox(NULL,"日期输入错误","错误!",MB_OK);
                exit(0);
            }
        }
        else
        {
            if(month==4||month==6 ||month==9||month==11)//郑志成在此调试,时间2014/11/15,考虑月份不周全,进行完善
                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);
        }
}

//定义Time类的派生类CFinnance,派生方式的公用派生
typedef class CFinance:public Time
{
//定义派生类的公用成员,也就是在基类的基础上新增加的成员
public:
    int year,month,day;//定义年月日
    double Income,Output;//定义收入和支出的变量
    CFinance *next;//定义一个指针变量
} Infor;

void SearchIncomeInfor(Infor *head);//查询收入的函数
void SearchOutputInfor(Infor *head);//查询支出的函数
int menu_select();//菜单的选择函数
void SearchDateInfor(Infor *head);//查找日期的函数

//首先创建一个空链表进行存储
Infor *Inforinitlist()    //创建信息空链表
{
    Infor *head;
    head=(Infor*)malloc(sizeof(Infor));
    head->next =NULL;
    return head;
}

int menu_select()
{
    char *m[6]= {"1.录入财务信息","2.浏览财务信息","3.查询财务信息","4.统计财务信息",
                 "5.退出财务系统"
                };
    char *c;
    c=new char[50];
    do
    {
        system("cls");//系统清屏
        cout<<"\t\t----------财务管理系统总菜单----------------"<<endl<<endl;
        for(int i=0; i<5; i++)
        cout<<"\t\t\t"<<m[i]<<endl<<endl;
        cout<<"请用户做出选择:"<<endl;
        cout<<"Choice"<<endl;
        cin>>c;
    }
    while(c[0]<'1'||c[0]>'5'||c[1]);
    return(c[0]-'0');
}

void InputFinanceInfor(Infor *head)
{
    system("cls");//系统清屏
    cout<<"\t\t------------------输入财务信息---------------------"<<endl<<endl;
    Infor *p1,*p2,*p3;
    p3=head;
    if(NULL!=p3->next)
    {
        p3=p3->next;
    }
    p2=p3;
    char input,*in;
    in=&input;
    do
    {
        p1=(Infor*)malloc(sizeof(Infor));
        cout<<"\t\t\t年份整形变量[int]: ";
        cin>>p1->year;
        cout<<endl<<"\t\t\t月份整形变量[int]: ";
        cin>>p1->month;
        cout<<endl<<"\t\t\t日期整形变量[int]: ";
        cin>>p1->day;
        cout<<endl<<"\t\t\t收入浮点型变量[double]: ";
        cin>>p1->Income;
        cout<<endl<<"\t\t\t支出浮点型变量[double]: ";
        cin>>p1->Output;
        p2->next=p1;
        p2=p1;
        cout<<endl<<"\t是否继续输入?(Yes/No)";
        cin>>*in;
        system("pause");//调用系统函数,按任意键继续程序
    }
    while(toupper(input)!='No');
    p2->next=NULL;
}

void ListFinanceInfor(Infor *head)
{
    Infor *p;
    p=head->next;
    if(p!=NULL)
    {
        system("cls");//系统清屏
        cout<<endl<<"\t\t==========浏览全部财务信息=========="<<endl;
        while(p!=NULL)
        {
            cout<<"\t\t-------------------------------------------"<<endl<<endl;
            cout<<setw(8)<<"\t\t年:"<<p->year<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"\t\t月:"<<p->month<<endl;
            cout<<setw(8)<<"\t\t日: "<<p->day<<endl;//sewt()是定义字段长度的函数
            cout<<"\t\t收入情况:"<<p->Income<<endl;
            cout<<"\t\t支出情况:"<<p->Output<<endl;
            cout<<"\t\t=================================="<<endl;
            p=p->next;
        }
    }
}

//查询总菜单
void SearchMenu(Infor *head)
{
    Infor *p;
    p=head->next;
    int ch;
    system("cls");//系统清屏
    cout<<endl<<"**********财务查询**********"<<endl<<endl;
    cout<<"=========1.支出查询========="<<endl<<endl;
    cout<<"=========2.收入查询========="<<endl<<endl;
    cout<<"=========3.日期查询========="<<endl<<endl;
    cout<<"=========4.返回上层========="<<endl<<endl;
    cout<<"****************************"<<endl<<endl;
    cout<<"请用户做出选择:"<<endl;
    cout<<"Option:";
    cin>>ch;
    switch (ch)
    {
    case 1:
        SearchOutputInfor(p);
        system("pause");//调用系统函数,按任意键继续程序
        break;
    case 2:
        SearchIncomeInfor(p);
        system("pause");//调用系统函数,按任意键继续程序
        break;
    case 3:
        SearchDateInfor(p);
        system("pause");//调用系统函数,按任意键继续程序
        break;
    case 4:
        system("cls");//系统清屏
        return;
    default:
        break;
    }
}

void SearchOutputInfor(Infor *head)
{
    Infor *p;
    p=head;
    system("cls");//系统清屏
    cout<<endl<<endl<<"\t\t====================支出查询==============="<<endl;
    while(p!=NULL)
    {
        if(0!=p->Output)
        {
            cout<<setw(8)<<"年:"<<p->year<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"月:"<<p->month<<endl;
            cout<<setw(8)<<"日:"<<p->day<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"支出:"<<p->Output<<endl;
            cout<<"\t\t ---------------------------------------"<<endl;
        }
        p=p->next;
    }
}

void SearchIncomeInfor(Infor *head)
{
    Infor *p;
    p=head;
    system("cls");//系统清屏
    cout<<endl<<endl<<"\t\t====================收入查询==============="<<endl;
    while(p!=NULL)
    {
        if(0!=p->Output)
        {
            cout<<setw(8)<<"年:"<<p->year<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"月:"<<p->month<<endl;
            cout<<setw(8)<<"日:"<<p->day<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"收入:"<<p->Income<<endl;//sewt()是定义字段长度的函数
            cout<<"\t\t ---------------------------------------"<<endl;
        }
        p=p->next;
    }
}

void SearchDateInfor(Infor *head)
{
    int x,y,z;
    Infor *p;
    p=head;
    cout<<"请输入日期。"<<endl;
    cin>>x>>y>>z;
    Time1.GetTime(x,y,z);
    Time1.CheckTime();
    cout<<endl<<endl<<"\t\t====================日期查询==============="<<endl;
    while(x!=p->year||y!=p->month||z!=p->day)
    {
        if(p->next ==NULL)
        {
            cout<<"未找到记录!"<<endl;
            cout<<"\t\t----------------------------------------"<<endl;
            return;
        }

        p=p->next;
    }
    system("cls");//系统清屏
    cout<<setw(8)<<"年:"<<p->year<<endl;//sewt()是定义字段长度的函数
    cout<<setw(8)<<"月:"<<p->month<<endl;//sewt()是定义字段长度的函数
    cout<<setw(8)<<"日:"<<p->day<<endl;//sewt()是定义字段长度的函数
    cout<<setw(8)<<"收入:"<<p->Income<<endl;//sewt()是定义字段长度的函数
    cout<<setw(8)<<"支出:"<<p->Output<<endl;//sewt()是定义字段长度的函数
    cout<<"\t\t ---------------------------------------"<<endl;
}

void CalculateMonthInfor(Infor *head)
{
    int x,y;
    Infor *p;
    p=head;
    system("cls");//系统清屏
    cout<<endl<<endl<<"\t\t====================按月统计==============="<<endl;
    cout<<"输入年份,月份!"<<endl;
    cin>>x>>y;
    while(p!=NULL)
    {
        if(x==p->year&&y==p->month)
        {
            cout<<setw(8)<<"年:"<<p->year<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"月:"<<p->month<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"日:"<<p->day<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"支出:"<<p->Output<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"收入:"<<p->Income<<endl;//sewt()是定义字段长度的函数
            cout<<"\t\t ---------------------------------------"<<endl;
        }
        p=p->next;
    }
}

void CalculateYearInfor (Infor *head)
{
    int x;
    Infor *p;
    p=head;
    system("cls");//系统清屏
    cout<<endl<<endl<<"\t\t====================按年统计==============="<<endl;
    cout<<"输入年份!"<<endl;
    cin>>x;
    while(p!=NULL)
    {
        if(x==p->year)
        {
            cout<<setw(8)<<"年:"<<p->year<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"月:"<<p->month<<endl;
            cout<<setw(8)<<"日:"<<p->day<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"支出:"<<p->Output<<endl;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"收入:"<<p->Income<<endl;//sewt()是定义字段长度的函数
            cout<<"\t\t ---------------------------------------"<<endl;
        }
        p=p->next;
    }
}

void CalculateDayInfor (Infor *head)
{
    int x,y,z;
    Infor *p;
    p=head;
    system("cls");//系统清屏
    cout<<endl<<endl<<"\t\t====================按日统计==============="<<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;//sewt()是定义字段长度的函数
            cout<<setw(8)<<"月:"<<p->month<<endl;
            cout<<setw(8)<<"日:"<<p->day<<endl;
            cout<<setw(8)<<"支出:"<<p->Output<<endl;
            cout<<setw(8)<<"收入:"<<p->Income<<endl;//sewt()是定义字段长度的函数
            cout<<"\t\t ---------------------------------------"<<endl;
        }
        p=p->next;
    }
}

//宋政,贾超负责调试,时间2014/11/15针对清屏功能

void CalculateInfor(Infor *head)
{
    Infor *p;
    p=head->next;
    int ch;
    system("cls");//系统清屏
    cout<<endl<<"**********财务统计**********"<<endl<<endl;//李烁界面创建,时间2014/11/13,进行基本输出语句的使用和完善界面的美化外包
    cout<<"=========1.按年统计========="<<endl<<endl;
    cout<<"=========2.按月统计========="<<endl<<endl;
    cout<<"=========3.按日统计========="<<endl<<endl;
    cout<<"=========4.返回上层========="<<endl<<endl;
    cout<<"****************************"<<endl<<endl;
    cout<<"Option:";
    cin>>ch;
    switch (ch)
    {
    case 1:
        CalculateYearInfor(p);
        system("pause");//调用系统函数,按任意键继续程序
        break;
    case 2:
        CalculateMonthInfor(p);
        system("pause");//调用系统函数,按任意键继续程序
        break;
    case 3:
        CalculateDayInfor(p);
        system("pause");//调用系统函数,按任意键继续程序
        break;
    case 4:
        system("cls");//系统清屏
        return;
    default:
        break;
    }
}

int main()
{
    Infor *st,*head=NULL;
    system("color 1D");//调用系统的界面颜色函数
    st=Inforinitlist();
    int choice=0;
    while(choice!=6)
    {
        choice=menu_select();
        switch(choice)
        {
        case 1:
            InputFinanceInfor(st);
            system("pause");//调用系统函数,按任意键继续程序
            break;
        case 2:
            ListFinanceInfor(st);
            system("pause");//调用系统函数,按任意键继续程序
        case 3:
            SearchMenu(st);
            system("pause");//调用系统函数,按任意键继续程序
            break;
        case 4:
            CalculateInfor(st);
            system("pause");//调用系统函数,按任意键继续程序
            break;
        case 5:
            exit(0);
            break;
        default:
            ;
        }
    }
    return 0;
}

//刘继国负责创建主要核心代码。时间2014/11/20日进行最终完善






  • 5
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值