C语言家庭财务管理系统代码

合集下载

家庭财务管理系统课程设计的原代码

家庭财务管理系统课程设计的原代码

1、frm_borrowgo.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Str_text As StringDim strflag As StringPrivate Sub cmd_add_Click()txt_man。

Locked = Falsetxt_way。

Locked = Falsetxt_money。

Locked = FalseCombo1。

Locked = FalseCheck1.Enabled = TrueDTPicker1。

Enabled = Truetxt_man。

Text = ”"txt_way。

Text = ””txt_money。

Text = ”"Combo1.Text = "”strflag = "添加”Cmdsave。

Enabled = TrueEnd SubPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_del_Click()Dim A As BooleanA = MsgBox("是否真的要删除这条记录?", vbOKCancel + 32 + 256, "删除")If A = True ThenExeCutesql "delete from 借出where 得款人=’”&txt_man。

Text & ”’", Str_textMsgBox ”记录已删除!”,, "删除"If Mydb。

RecordCount 〉0 ThenMydb.MoveNextIf Mydb.EOF Then Mydb.MoveLastCall DbCall BangdingLabel7.Caption = Mydb。

C语言财务管理系统(源代码)教案.doc

C语言财务管理系统(源代码)教案.doc
void initialize();
void save_to_file();
void clear_data();
fi_data *get_last();
fi_data *get_previous(fi_data *p);
void input_info(fi_info *info);
void show_info(fi_data *p[],int count);
fflush(stdin);
getchar();
}
else
{
menu_fun[selected]();
}
selected=0;
}
}
void add_income()
{
fi_data *p=(fi_data *)malloc(sizeof(fi_data));
memset(p,0,sizeof(fi_data));
void delete_payout();
void update_payout();
void count_total();
void quit();
void search_data(fi_type type);
void delete_data(fi_type type);
void update_data(fi_type type);
input_info(&(p->info));
p->info.type=payout;
if(head==NULL)
{
head=p;
}
else
{
get_last(head)->next=p;
}
}
void search_payout()

c语言编写-家庭财务管理系统

c语言编写-家庭财务管理系统
s[recNumber].in=Tm.in;
strcpy(s[recNumber].intime,Tm.intime);
s[recNumber].out=Tm.out;
strcpy(s[recNumber].outtime,Tm.outtime);
if (fp==NULL) /*判断是否打开成功*/
{
printf("\n打开文件%s失败!按任意键结束!\n",Da);
exit(0);
}
while(fread(&Tm,sizeof(money),1,fp)!=(int)NULL) /*从文件中读取数据,是否读取成功*/
fp=fopen(Da,"ab+");
if (fp==NULL) /*判断文件是否成功打开*/
{
printf("\n 打开文件 %s 失败!按任意键结束!\n",Da);
exit(0);
}
while(fread(&ch,sizeof(money),1,fp)!=(int)NULL) /*从文件中读取数据并判断是否成功*/
scanf("%f",&Tm.in);
printf("输入收入时间:");
scanf("%s",Tm.intime);
printf("输入成员支出:");
scanf("%f",&Tm.out);
printf("输入支出时间:");
{ printf("###############################################\n");

C#程序设计-家庭账单管理系统

C#程序设计-家庭账单管理系统

C#程序设计作业——家庭账本管理系统系别计算机与通信工程学院专业计算机科学有技术班级4110415姓名张振一、程序说明课题为:家庭账单系统;使用工具:visual studio 2013 系统用户名:zhangzhen 密码:12345经上网查找资料,最终确定该系统应有以下几个功能:1)登陆,注册功能2)成员管理功能,包括修改资料,添加成员等3)最核心的消费记录管理功能,包括添加纪录,查看今天记录,本周记录等程序有四个主要的界面:1)登陆、注册界面2)用户管理界面主要功能包括修改资料、添加成员等,当然从此界面可以查看消费记录,退出系统等3)消费记录界面主要功能包括添加纪录、查看各个时间段消费记录的功能,当然可以进入成员管理界面和退出系统4)消费记录管理界面主要是添加消费记录的功能。

二、核心代码1)成员管理界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace home{public partial class Form2 : Form{public int count, pagecount, pagesize, page;data dataconn = new data();public Form2(){InitializeComponent();string cname = ame;bel1.Text = "用户:"+cname + " - 天天好心情哦!~";page = 1;pagesize = 12;getpagecount();DataSet ds = dataconn.getlist("select top " + pagesize + " username,password,cname,birthday,id from cuser order by id asc");this.dataGridView1.DataSource = ds.Tables[0].DefaultView;this.dataGridView1.Columns[0].HeaderText = "用户名";this.dataGridView1.Columns[1].HeaderText = "密码";this.dataGridView1.Columns[2].HeaderText = "姓名";this.dataGridView1.Columns[3].HeaderText = "生日";this.dataGridView1.Columns[4].Visible = false;DataGridViewButtonColumn btn1 = new DataGridViewButtonColumn();btn1.HeaderText = "";btn1.Text = "修改"; = "edit";btn1.Width = 60;eColumnTextForButtonValue = true;this.dataGridView1.Columns.Add(btn1);DataGridViewButtonColumn btn = new DataGridViewButtonColumn();btn.HeaderText = "";btn.Text = "删除"; = "del";btn.Width = 60;eColumnTextForButtonValue = true;this.dataGridView1.Columns.Add(btn);this.dataGridView1.RowPostPaint += new DataGridViewRowPostPaintEventHandler(DrawRowIndex);this.dataGridView1.CellFormatting += newDataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);this.button1.Enabled = false;this.button2.Enabled = false;if (pagecount > page){this.button1.Enabled = true;}}private void button1_Click(object sender, EventArgs e){kk(1);}public void getpagecount(){DataSet dw = dataconn.getlist("select * from cuser");count = dw.Tables[0].Rows.Count;if (count % pagesize == 0){pagecount = count / pagesize;}else{pagecount = count / pagesize + 1;}bel2.Text = "共"+pagecount.ToString()+" 页当前第"+page.ToString()+" 页";}public void kk(int ss){if (ss == 0){page -= 1;}else{page += 1;}getpagecount();string sql = "";if (page <= 1){page = 1;sql = "select top " + pagesize + "username,password,cname,birthday,id from cuser order by id asc";this.button2.Enabled = false;if (pagecount > page){this.button1.Enabled = true;}}else if (page >= pagecount){sql = "select top " + pagesize + "username,password,cname,birthday,id from cuser where id > (select max(id) from (select top " + pagesize * (page - 1) + " id from cuser order by id asc) as tem)";if (pagecount > 1){this.button2.Enabled = true;}this.button1.Enabled = false;}else{sql = "select top " + pagesize + "username,password,cname,birthday,id from cuser where id > (select max(id) from (select top " + pagesize * (page - 1) + " id from cuser order by id asc) as tem)";this.button2.Enabled = true;this.button1.Enabled = true;}DataSet ds = dataconn.getlist(sql);this.dataGridView1.DataSource = ds.Tables[0].DefaultView;}private void button2_Click(object sender, EventArgs e){kk(0);}private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e){if (dataGridView1.Columns[e.ColumnIndex].Name == "del"){int id =Convert.ToInt16(dataGridView1.Rows[e.RowIndex].Cells[6].Value);if (id == 1){MessageBox.Show("怎么能够删除创始人呢!","友情提示");return;}else{dataconn.update("delete from cuser where id = " + id);MessageBox.Show("成功删除一个成员!", "友情提示");page = 2;getpagecount();kk(0);}}if (dataGridView1.Columns[e.ColumnIndex].Name == "edit"){user userfrm = newuser(this.dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(),this.dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(),this.dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(),this.dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(),this.dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(),this);userfrm.ShowDialog();}}private void Form2_FormClosing(object sender, FormClosingEventArgs e){Application.Exit();}private void button3_Click(object sender, EventArgs e){user userfrm = new user("0", "", "", "",DateTime.Now.Date.ToString(), this);userfrm.ShowDialog();}private void button4_Click(object sender, EventArgs e){Form3 frm3 = new Form3();frm3.Show();this.Hide();}private void button5_Click(object sender, EventArgs e){int uid = Form1.uid;SqlDataReader dr = dataconn.read("select * from cuser where id = " + uid);while (dr.Read()){user userfrm = new user(uid.ToString(),dr["username"].ToString(), dr["password"].ToString(), dr["cname"].ToString(),dr["birthday"].ToString(), this);userfrm.ShowDialog();}dr.Close();}private void button6_Click(object sender, EventArgs e){Application.Exit();}private void DrawRowIndex(object sender, DataGridViewRowPostPaintEventArgs e){Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,e.RowBounds.Location.Y,this.dataGridView1.RowHeadersWidth - 4,e.RowBounds.Height);TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),this.dataGridView1.RowHeadersDefaultCellStyle.Font,rectangle,this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor,TextFormatFlags.VerticalCenter | TextFormatFlags.Right);}private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e){if (e.ColumnIndex == 3){if (e.Value != null && e.Value.ToString().Length > 0){e.Value = new string('$', e.Value.ToString().Length);}}}}}2)消费记录管理界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Drawing.Imaging;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using System.Collections;namespace home{public partial class Form3 : Form{data dataconn = new data();public int pagesize, count, pagecount, page;public string key = "";public string jlsql = "";public string psql = "";public Form3(){InitializeComponent();pagesize = 22;page = 1;getpagecount();DataSet ds = dataconn.getlist("select top " + pagesize + " * from cords order by id desc");this.dataGridView1.DataSource = ds.Tables[0].DefaultView;this.dataGridView1.Columns[0].Visible = false;this.dataGridView1.Columns[1].HeaderText = "产品名称";this.dataGridView1.Columns[2].HeaderText = "类型";this.dataGridView1.Columns[3].HeaderText = "单价";this.dataGridView1.Columns[4].HeaderText = "费用";this.dataGridView1.Columns[5].HeaderText = "日期";this.dataGridView1.Columns[6].HeaderText = "星期";this.dataGridView1.Columns[7].HeaderText = "消费者";this.dataGridView1.Columns[8].HeaderText = "备注";DataGridViewButtonColumn btn1 = new DataGridViewButtonColumn();btn1.HeaderText = "";btn1.Text = "修改"; = "edit";btn1.Width = 60;eColumnTextForButtonValue = true;this.dataGridView1.Columns.Add(btn1);DataGridViewButtonColumn btn = new DataGridViewButtonColumn();btn.HeaderText = "";btn.Text = "删除"; = "del";btn.SortMode = DataGridViewColumnSortMode.NotSortable;btn.Width = 60;eColumnTextForButtonValue = true;this.dataGridView1.Columns.Add(btn);this.dataGridView1.RowPostPaint += new DataGridViewRowPostPaintEventHandler(DrawRowIndex);this.button1.Enabled = false;this.button2.Enabled = false;if (pagecount > page){this.button1.Enabled = true;}getcords();SqlDataReader dr1 = dataconn.read("select * from ptype");ArrayList list = new ArrayList();list.Add(new DictionaryEntry("所有类型", ""));if (dr1.HasRows){while (dr1.Read()){list.Add(new DictionaryEntry(dr1["ptype"].ToString(), dr1["ptype"].ToString()));}this.ptype.DataSource = list;this.ptype.DisplayMember = "key";this.ptype.ValueMember = "value";}dr1.Close();}public void kk(int ss){if (ss == 0){page -= 1;}else{page += 1;}getpagecount();string keysql = "";keysql = " and product like '%" + key + "%' ";string sql="";if (page <= 1){page = 1;sql = "select top " + pagesize + " * from cords where id is not null " + keysql + jlsql + psql + " order by ctime desc";this.button2.Enabled = false;if (pagecount > page){this.button1.Enabled = true;}}else if (page >= pagecount){sql = "select top " + pagesize + " * from cords where ctime < (select min(ctime) from (select top " + (page - 1) * pagesize + " ctime from cords order by ctime desc) as temp) order by ctime desc";if (pagecount > 1){this.button2.Enabled = true;}this.button1.Enabled = false;}else{sql = "select top " + pagesize + " * from cords where ctime < (select min(ctime) from (select top " + (page - 1) * pagesize + " ctime from cords order by ctime desc) as temp) order by ctime desc";this.button2.Enabled = true;this.button1.Enabled = true;}DataSet ds = dataconn.getlist(sql);this.dataGridView1.DataSource = ds.Tables[0].DefaultView;getcords();SqlDataReader dr1 = dataconn.read("select * from ptype");ArrayList list = new ArrayList();list.Add(new DictionaryEntry("所有类型",""));if (dr1.HasRows){while (dr1.Read()){list.Add(new DictionaryEntry(dr1["ptype"].ToString(), dr1["ptype"].ToString()));}this.ptype.DataSource = list;this.ptype.DisplayMember = "key";this.ptype.ValueMember = "value";}dr1.Close();}public void getpagecount(){DataSet dw = dataconn.getlist("select * from cords");count = dw.Tables[0].Rows.Count;if (count % pagesize == 0){pagecount = count / pagesize;}else{pagecount = count / pagesize + 1;}bel2.Text = "共" + pagecount.ToString() + " 页当前第" + page.ToString() + " 页";}private void button2_Click(object sender, EventArgs e){kk(0);}private void button1_Click(object sender, EventArgs e){kk(1);}private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e){if (dataGridView1.Columns[e.ColumnIndex].Name == "del"){int id =Convert.ToInt16(dataGridView1.Rows[e.RowIndex].Cells[2].Value);dataconn.update("delete from cords where id = " + id);MessageBox.Show("成功删除一个消费记录!","友情提示");page = 2;getpagecount();kk(0);}if (dataGridView1.Columns[e.ColumnIndex].Name == "edit"){cords cordsfrm = newcords(int.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString()), this);cordsfrm.ShowDialog();}}private void button3_Click(object sender, EventArgs e){cords cordsfrm = new cords(0, this);cordsfrm.ShowDialog();}private void button4_Click(object sender, EventArgs e){Form2 frm2 = new Form2();frm2.Show();this.Hide();}private void button6_Click(object sender, EventArgs e){Application.Exit();}private void button5_Click(object sender, EventArgs e){key = this.textBox1.Text;if (ptype.Text != "所有类型"){psql = " and ptype='" + this.ptype.Text + "' ";}else{psql = "";}kk(0);}private void button7_Click(object sender, EventArgs e){key = "";jlsql = "";psql = "";kk(0);}public void getcords(){double cords = 0;for (int i = 0; i < this.dataGridView1.Rows.Count; i++){cords +=Convert.ToDouble(this.dataGridView1.Rows[i].Cells["spend"].Value);}bel4.Text = "消费金额总计:" + cords.ToString();}private void button8_Click(object sender, EventArgs e){jlsql = " and datediff(Month,ctime,getdate())=0 ";key = "";psql = "";kk(0);}private void button9_Click(object sender, EventArgs e){jlsql = " and datediff(week,ctime,getdate())=0 ";key = "";psql = "";kk(0);}private void button10_Click(object sender, EventArgs e){jlsql = " and datediff(qq,ctime,getdate())=0 ";key = "";psql = "";kk(0);}private void button11_Click(object sender, EventArgs e){jlsql = " and datediff(Day,ctime,getdate())=0 ";key = "";psql = "";kk(0);}private void DrawRowIndex(object sender, DataGridViewRowPostPaintEventArgs e){Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,e.RowBounds.Location.Y,this.dataGridView1.RowHeadersWidth - 4,e.RowBounds.Height);TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),this.dataGridView1.RowHeadersDefaultCellStyle.Font,rectangle,this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor,TextFormatFlags.VerticalCenter | TextFormatFlags.Right);}}}。

家庭支出管理系统详细代码

家庭支出管理系统详细代码

先在D盘先建立“密码.txt(在里面写入初始六位密码)”;“支出信息。

txt”即可。

代码:#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <string.h>#include <conio.h>#include <malloc.h>typedef struct //定义结构体{char type[20];//消费类型float Getsum;//消费金额char place[20];//消费地点int time;//消费时间}family;family fam[80];int menu()//显示该系统所具备的功能{char c;do{system("cls");//清屏printf("\t\t***************************\n");printf("\t\t**********菜单系统*********\n");printf("\t\t|1.输入消费信息|\n");printf("\t\t|2.计算消费总和|\n");printf("\t\t|3.显示消费情况|\n");printf("\t\t|4.对同种类型消费进行排序并显示|\n");printf("\t\t|5.消费情况分析|\n");printf("\t\t|6.保存数据|\n");printf("\t\t|0.退出系统|\n");printf("\t\t***************************\n");printf("\t\t***************************\n");printf("\t\t\t请对应选择所需选项(0-6):");c=getchar();}while(c<'0'||c>'6');return(c-'0');}void password()//密码验证和密码修改{int m;printf("\t\t****************登陆界面****************\n");printf("\t\t****************************************\n");printf("\t\t**\t\t1.密码修改**\n");printf("\t\t**\t\t2.登陆**\n");printf("\t\t****************************************\n");printf("\t\t****************************************\n");printf("\t\t\t请输入您所要的选项(1,2):");scanf("%d",&m);getchar();switch(m){case 1://密码修改{int i,j;char a[7],b[7],c[7],d[7];FILE *fp1; FILE *fp2;fp1=fopen("D:\\密码.txt","r");if(!fp1){printf("file cannot be opened");exit(1);}for(i=0;!feof(fp1);i++) //feof判断文件是否结束{a[i]=fgetc(fp1);}fclose(fp1);printf("\t\t\t请输入原密码:");for(j=0;j<7;j++){scanf("%c",b+j);//判断数组b是否和原密码是否相等if(b[j]>='0'&&b[j]<='9'||b[j]>='a'&&b[j]<='z'||b[j]>='A'&&b[j]<='Z')putchar('*');}if(a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2]&&a[3]==b[3]&&a[4]==b[4]&&a[5]==b[5]) {do{printf("\t\t\t请设置您的新密码: ");for(j=0;j<7;j++){scanf("%c",c+j);if(c[j]>='0'&&c[j]<='9'||c[j]>='a'&&c[j]<='z'||c[j]>='A'&&c[j]<='Z')putchar('*');}printf("\t\t\t请确认您的新密码: ");for(j=0;j<7;j++){scanf("%c",d+j);if(d[j]>='0'&&d[j]<='9'||d[j]>='a'&&d[j]<='z'||d[j]>='A'&&d[j]<='Z')putchar('*');}}while(!(c[0]==d[0]&&c[1]==d[1]&&c[2]==d[2]&&c[3]==d[3]&&c[4]==d[4]&&c[5]==d[5]));//利用do while语句进行判定两次密码是否成功!fp2=fopen("D:\\密码.txt","w+");if(!fp2){printf("the file cannot be opened!");exit(1);}i=0;while (i<6){fprintf(fp2,"%c",c[i]);i++;}fclose(fp2);printf("\t\t\t密码修改成功!\n");}else{printf("\t\t\t密码错误\n");exit(0);}}case 2://密码验证{char e[7],f[7];int n=0;int i,j;FILE *fp1;fp1=fopen("D:\\密码.txt","r");if(!fp1){printf("the file cannot be opened!");exit(1);}for(i=0;!feof(fp1);i++){ e[i]=fgetc(fp1); }do{printf("\t\t\t请输入六位数密码:");for(j=0;j<7;j++){scanf("%c",f+j);if(f[j]>='0'&&f[j]<='9'||f[j]>='a'&&f[j]<='z'||f[j]>='A'&&f[j]<='Z')putchar('*');}if(!(e[0]==f[0]&&e[1]==f[1]&&e[2]==f[2]&&e[3]==f[3]&&e[4]==f[4]&&e[5]==f[5])){printf("\n密码错误!请重新输入:\n");n++;}if (n>3){printf("error\n");exit(0);}}while(!(e[0]==f[0]&&e[1]==f[1]&&e[2]==f[2]&&e[3]==f[3]&&e[4]==f[4]&&e[5]==f[5]));//利用do~while语句进行判定密码是否错误!printf("\n\t\t\t欢迎使用!\n");}}}int Input(family sum[],int n)//输入消费信息{int i=0;char sign='y',x[10];while(sign!='n'&&sign!='N'){printf("\t\t\t种类:");scanf("\t\t\t%s",sum[n+i].type);printf("\t\t\t支出(大于0):");scanf("\t\t\t%f",&sum[n+i].Getsum);printf("\t\t\t地点:");scanf("\t\t\t%s",sum[n+i].place);printf("\t\t\t时间(0-31):");scanf("\t\t\t%d",&sum[n+i].time);if(sum[n+i].time<1||sum[n+i].time>31)return false;gets(x);printf("\t\t\t需要再次输入吗?(y/n)");scanf("\t\t\t%c",&sign);//判断是否需要重新输入i++;}}void Getsum(family sum[], int n) //计算消费总金额{float getsum=0;int i=0;for(i=0;i<n;i++){getsum+=sum[i].Getsum;}printf("\t\t\t%f\n",getsum);}void Showitems(family sum[],int n)//输出所输入的消费信息{int i;printf("\t\t\t--------------------------------------\n");printf("\t\t\t种类支出地点时间\n");printf("\t\t\t--------------------------------------\n");for(i=1;i<n+1;i++){printf("\t\t\t%-8s %-12f %-8s %-10d\n",sum[i-1].type,sum[i-1].Getsum,sum[i-1].place,sum[i-1].ti me);if(i>1&&i%10==0)//这边为什么会有i%10==0(保证输入多次信息的时候可以一次性显示) {printf("\t\t\t----------------\n");printf("\t\t\t");printf("\t\t\t----------------\n");}}printf("\t\t\t");system("pause");}void sort(family sum[],int n)//对消费信息进行归类和选择法排序升序排名{int i,j;family temp;FILE *fp;fp=fopen("D:\\支出信息.txt","a+");if(fp==NULL){printf("\t\t\tthe file cannot be opened!\n");exit(1);}for(i=0;i<n-1;i++)for(j=i+1;j<n;j++){if(strcmp(sum[i].type,sum[j].type)==1){temp=sum[j];sum[i]=temp;sum[j]=sum[i]; }elseif(strcmp(sum[j].type,sum[i].type)==0){if(sum[i].Getsum>sum[j].Getsum){temp=sum[j];sum[j]=sum[i];sum[i]=temp;}}}}fclose(fp);}//排序后是写入文件的写入数组解决不了void Analyseitems(family sum[],int n) //求各种消费类型的金额占总金额的百分比//在解决相同type的问题上可以利用数组去存储字符串,但系统一直崩溃。

C语言家庭财务管理系统

C语言家庭财务管理系统
do
{
n=scanf("%s %s %f",J[i].rq,J[i].zy,&J[i].xf);
if(J[i]Biblioteka xf==0)break;/*收入和支出为0则退出*/
if(n==3)i++;
}
while(n==3);
N=i; /*修改家庭财务信息记录数*/
}
void SaveJ(char file[])/*保存家庭财务信息关系*/
{
int n,i=0;
FILE *fp=fopen("JTCWGLXT.txt","r");
char s[80];fgets(s,80,fp);
do
{
n=fscanf(fp,"%s %s %f %f",J[i].rq,J[i].zy,&J[i].xf,&J[i].ye);
if(n==4)i++;/*若读到4个数据则i加1*/
}
while(n==4);
fclose(fp);
return i;
}
void DispJ()/*显示家庭财务信息*/
{
int i;
printf("%s %8s %8.2f%8.2f\n",J[0].rq,J[0].zy,J[0].xf,J[0].ye);
for(i=1;i<N;i++)
printf("%s %8s %8.2f%8.2f\n",J[i].rq,J[i].zy,J[i].xf,J[i-1].ye+J[i].xf);
fprintf( fp,"%s %8s %8.2f%8.2f\n",J[i].rq,J[i].zy,J[i].xf,J[i-1].ye+J[i].xf);

简单家庭理财C语言代码

简单家庭理财C语言代码

/******头文件(.h)***********/#include "stdio.h" /*I/O函数*/#include "stdlib.h" /*标准库函数*/#include "string.h"/*字符串函数*/#include "ctype.h" /*字符操作函数*/#define M 200 /*定义常数表示记录数*/typedef struct /*定义数据结构*/{char name[20]; /*姓名*/char units[30]; /*单位*/char tele[10]; /*电话*/char product_company[30];/* 生产厂家*/char designer[30]; /* 设计者*/char price[10]; /* 价格*/char kucun[10]; /* 库存量*/char year[4]; /* 出厂年份*/char month[2]; /* 出厂月份*/char day[2]; /* 出厂*/}ADDRESS;/******以下是函数原型*******/int enter(ADDRESS t[]); /*输入记录*/void list(ADDRESS t[],int n); /*显示记录*/void search(ADDRESS t[],int n); /*按姓名查找显示记录*/ int delete(ADDRESS t[],int n); /*删除记录*/int add(ADDRESS t[],int n); /*插入记录*/void save(ADDRESS t[],int n); /*记录保存为文件*/int load(ADDRESS t[]); /*从文件中读记录*/void display(ADDRESS t[]); /*按序号查找显示记录*/ void sort(ADDRESS t[],int n); /*按姓名排序*/void modify_price(ADDRESS t[],int n); /*快速查找记录*/ void copy(); /*文件复制*/void print(ADDRESS temp); /*显示单条记录*/int find(ADDRESS t[],int n,char *s) ; /*查找函数*/int menu_select(); /*主菜单函数*//******主函数开始*******/main(){int i;ADDRESS adr[M]; /*定义结构体数组*/int length=0; /*保存记录长度*/clrscr(); /*清屏*/for(;;)/*无限循环*/{clrscr(); /*清屏*/switch(menu_select()) /*调用主菜单函数,返回值整数作开关语句的条件*/{case 0:length=enter(adr);break;/*输入记录*/case 1:list(adr,length);break; /*显示全部记录*/case 2:search(adr,length);break; /*查找记录*/case 3:length=delete(adr,length);break; /*删除记录*/case 4:length=add(adr,length); break; /*插入记录*/case 5:save(adr,length);break; /*保存文件*/case 6:modify_kucun(adr,length); break; /*读文件*/case 7:display(adr);break; /*按序号显示记录*/case 8:sort(adr,length);break; /*按姓名排序*/case 9:modify_kucun(adr,length);break; /*快速查找记录*/case 10:copy();break; /*复制文件*/case 11:exit(0); /*如返回值为11则程序结束*/}}}/*菜单函数,函数返回值为整数,代表所选的菜单项*/menu_select(){char s[80];int c;/*gotoxy(1,25);*//* 将光标定为在第25行,第1列*/printf("press any key enter menu......\n");/*提示压任意键继续*/getch(); /*读入任意字符*/clrscr(); /*清屏*//*gotoxy(1,1); */printf("********************MENU*********************\n\n");printf(" 0. Enter record\n");printf(" 1. List the file\n");printf(" 2. Search record on name\n");printf(" 3. Delete a record\n");printf(" 4. add record \n");printf(" 5. Save the file\n");printf(" 6. Modify kucun\n");printf(" 7. Display record on order\n");printf(" 8. Sort to make new file\n");printf(" 9. Quick seek record\n");printf(" 10. Copy the file to new file\n");printf(" 11. Quit\n");printf("***********************************************\n");do{printf("\n Enter you choice(0~11):"); /*提示输入选项*/scanf("%s",s); /*输入选择项*/c=atoi(s); /*将输入的字符串转化为整型数*/}while(c<0||c>11); /*选择项不在0~11之间重输*/clrscr(); /*清屏*/return c; /*返回选择项,主程序根据该数调用相应的函数*/}/***输入记录,形参为结构体数组,函数值返回类型为整型表示记录长度*/int enter(ADDRESS t[]){int i,n;char *s;clrscr(); /*清屏*/do{printf("\nHow many numbers do you want to record?\nplease input the numbers you wanted:\n"); /*提示信息*/scanf("%d",&n); /*输入记录数*/if(n==0)printf("the num couldn't be '0'!Please enter again!");}while(n==0);printf("please input record! \n"); /*提示输入记录*/printf("name|unit|telephone|product_company|designer|price|kucun|year|mont h|day\n");printf("------------------------------------------------\n");for(i=0;i<n;i++){/*scanf("%s %s %s %s %s %s %s %s %s %s",t[i].name,t[i].units,t[i].tele,t[i].pr oduct_company,t[i].designer,t[i].price,t[i].kucun,t[i].year,t[i].month,t[i].day); *//*输入记录*/printf("name:"); /* 打印输出号码*/scanf("%s",&t[i].name);/* 用数组输入号码*/printf("unit:"); /* 打印输出名字*/scanf("%s",&t[i].units); /* 用数组输入姓名*/printf("telephone:");/* 打印输出性别*/scanf("%s",&t[i].tele);/* 用数组输入性别*/printf("product_company:"); /* 打印输出生日*/scanf("%s",&t[i].product_company); /* 用数组输入生日*/printf("designer:");/* 打印输出婚姻状况*/scanf("%s",&t[i].designer);/* 用数组输入婚姻状况*/printf("price:");/* 打印输出工作状况*/scanf("%s",&t[i].price);/* 用数组输入工作状况*/printf("kucun:");/* 打印输出工作状况*/scanf("%s",&t[i].kucun);/* 用数组输入工作状况*/printf("produce year:");/* 打印输出工作状况*/scanf("%s",&t[i].year);/* 用数组输入工作状况*/printf("produce month:");/* 打印输出工作状况*/scanf("%s",&t[i].month);/* 用数组输入工作状况*/printf("produce day:");/* 打印输出工作状况*/scanf("%s",&t[i].day);/* 用数组输入工作状况*/printf("-----------Ok!this record have been recorded!------------\n");}printf("the all have been recorded!\n");getch();clrscr();return n; /*返回记录条数*/}/*显示记录,参数为记录数组和记录条数*/void list(ADDRESS t[],int n){int i;clrscr();printf("\n\n*******************ADDRESS******************\n");printf("name|unit|telephone|product_company|designer|price|kucun|year|mont h|day\n");printf("------------------------------------------------------------------------\n");if(n!=0)for(i=0;i<n;i++){printf("%s/%s/%s/%s/%s/%s/%s/%s/%s/%s",t[i].name,t[i].units,t[i].tele,t[i].prod uct_company,t[i].designer,t[i].price,t[i].kucun,t[i].year,t[i].month,t[i].day);if((i+1)%10==0) /*判断输出是否达到10条记录*/{printf("Press any key continue...\n"); /*提示信息*/getch(); /*压任意键继续*/}}else printf("there is no record!\n");printf("************************end*******************\n");}/*查找记录*/void search(ADDRESS t[],int n){char s[20]; /*保存待查找姓名字符串*/int i; /*保存查找到结点的序号*//*clrscr(); */printf("please input the search name:\n");scanf("%s",s); /*输入待查找姓名*/i=find(t,n,s); /*调用find函数,得到一个整数*/if(i>n-1) /*如果整数i值大于n-1,说明没找到*/printf("not found!\n");elseprint(t[i]); /*找到,调用显示函数显示记录*/clrscr();}/*显示指定的一条记录*/void print(ADDRESS temp){/* clrscr(); */printf("\n\n********************************************\n");printf("name|unit|telephone|product_company|designer|price|kucun|year|mont h|day\n");/*printf("------------------------------------------------\n"); */printf("%s/%s/%s/%s/%s/%s/%s/%s/%s/%s",,temp.units,temp.tele, temp.product_company,temp.designer,temp.price,temp.kucun,temp.year,tem p.month,temp.day);printf("**********************end***********************\n");}/*查找函数,参数为记录数组和记录条数以及姓名s */int find(ADDRESS t[],int n,char *s){int i;for(i=0;i<n;i++)/*从第一条记录开始,直到最后一条*/{if(strcmp(s,t[i].name)==0) /*记录中的姓名和待比较的姓名是否相等*/return i; /*相等,则返回该记录的下标号,程序提前结结束*/}return i; /*返回i值*/}/*删除函数,参数为记录数组和记录条数*/int delete(ADDRESS t[],int n){char s[20]; /*要删除记录的姓名*/int ch=0;int i,j;printf("please deleted name\n"); /*提示信息*/scanf("%s",s);/*输入姓名*/i=find(t,n,s); /*调用find函数*/if(i>n-1) /*如果i>n-1超过了数组的长度*/printf("no found not deleted\n"); /*显示没找到要删除的记录*/ else{print(t[i]); /*调用输出函数显示该条记录信息*/printf("Are you sure delete it(1/0)\n"); /*确认是否要删除*/scanf("%d",&ch); /*输入一个整数0或1*/if(ch==1) /*如果确认删除整数为1*/{for(j=i+1;j<n;j++) /*删除该记录,实际后续记录前移*/{strcpy(t[j-1].name,t[j].name); /*将后一条记录的姓名拷贝到前一条*/strcpy(t[j-1].units,t[j].units); /*将后一条记录的单位拷贝到前一条*/strcpy(t[j-1].tele,t[j].tele); /*将后一条记录的电话拷贝到前一条*/strcpy(t[j-1].product_company,t[j].product_company);strcpy(t[j-1].designer,t[j].designer);strcpy(t[j-1].price,t[j].price);strcpy(t[j-1].kucun,t[j].kucun);strcpy(t[j-1].year,t[j].year);strcpy(t[j-1].month,t[j].month);strcpy(t[j-1].day,t[j].day);}n--; /*记录数减1*/}}return n; /*返回记录数*/}/*插入记录函数,参数为结构体数组和记录数*/int add(ADDRESS t[],int n)/*插入函数,参数为结构体数组和记录数*/{ADDRESS temp; /*新插入记录信息*/int i,j;char s[20],p; /*确定插入在哪个记录之前*/printf("please input the new record:\n");printf("************************************************\n");printf("name|unit|telephone|product_company|designer|price|kucun|year|mont h|day\n");/*printf("--------------------------------------------------\n");scanf("%s%s%s",,temp.units,temp.tele); *//* 输入插入信息*/ printf("name:"); /* 打印输出号码*/scanf("%s",&);/* 用数组输入号码*/printf("unit:"); /* 打印输出名字*/scanf("%s",&temp.units); /* 用数组输入姓名*/printf("telephone:");/* 打印输出性别*/scanf("%s",&temp.tele);/* 用数组输入性别*/printf("product_company:"); /* 打印输出生日*/scanf("%s",&temp.product_company); /* 用数组输入生日*/printf("designer:");/* 打印输出婚姻状况*/scanf("%s",&temp.designer);/* 用数组输入婚姻状况*/printf("price:");/* 打印输出工作状况*/scanf("%s",&temp.price);/* 用数组输入工作状况*/printf("kucun:");/* 打印输出工作状况*/scanf("%s",&temp.kucun);/* 用数组输入工作状况*/printf("produce year:");/* 打印输出工作状况*/scanf("%s",&temp.year);/* 用数组输入工作状况*/printf("produce month:");/* 打印输出工作状况*/scanf("%s",&temp.month);/* 用数组输入工作状况*/printf("produce day:");/* 打印输出工作状况*/scanf("%s",&temp.day);/* 用数组输入工作状况*/printf("-----------Ok!this record have been recorded!------------\n");printf("------------------------------------------------\n");K:printf("please input the wanted name's position to insert:\n");scanf("%s",s); /*输入插入位置的姓名*/i=find(t,n,s); /*调用find,确定插入位置*/if(i>n-1) /*如果i>n-1超过了数组的长度*/{printf("the name isn't exist!\n"); /*显示没找到要删除的记录*/printf("Are you want to continue to insert?Yes--y/No--any otherkey!\n");if(getch()=='y') goto K;}else{for(j=n-1;j>=i;j--) /*从最后一个结点开始向后移动一条*/{strcpy(t[j+1].name,t[j].name); /*当前记录的姓名拷贝到后一条*/strcpy(t[j+1].units,t[j].units); /*当前记录的单位拷贝到后一条*/strcpy(t[j+1].tele,t[j].tele); /*当前记录的电话拷贝到后一条*/strcpy(t[j+1].product_company,t[j].product_company);strcpy(t[j+1].designer,t[j].designer);strcpy(t[j+1].price,t[j].price);strcpy(t[j+1].kucun,t[j].kucun);strcpy(t[j+1].year,t[j].year);strcpy(t[j+1].month,t[j].month);strcpy(t[j+1].day,t[j].day);}strcpy(t[i].name,); /*将新插入记录的姓名拷贝到第i个位置*/strcpy(t[i].units,temp.units); /*将新插入记录的单位拷贝到第i个位置*/strcpy(t[i].tele,temp.tele); /*将新插入记录的电话拷贝到第i个位置*/strcpy(t[i].product_company,temp.product_company);strcpy(t[i].designer,temp.designer);strcpy(t[i].price,temp.price);strcpy(t[i].kucun,temp.kucun);strcpy(t[i].year,temp.year);strcpy(t[i].month,temp.month);strcpy(t[i].day,temp.day);n++; /*记录数加1*/return n; /*返回记录数*/}}/*保存函数,参数为结构体数组和记录数*/void save(ADDRESS t[],int n){int i;FILE *fp; /*指向文件的指针*/if((fp=fopen("record.txt","wb"))==NULL) /*打开文件,并判断打开是否正常*/{printf("can not open file\n");/*没打开*/exit(1); /*退出*/}printf("\nSaving file now!\n"); /*输出提示信息*/fprintf(fp,"there is %d records!",n); /*将记录数写入文件*/fprintf(fp,"\r\n"); /*将换行符号写入文件*/for(i=0;i<n;i++){fprintf(fp,"%s/%s/%s/%s/%s/%s/%s/%s/%s/%s",t[i].name,t[i].units,t[i].tele,t[i].p roduct_company,t[i].designer,t[i].price,t[i].kucun,t[i].year,t[i].month,t[i].day);/*格式写入记录*/fprintf(fp,"\r\n"); /*将换行符号写入文件*/}fclose(fp);/*关闭文件*/printf("****save success***\n"); /*显示保存成功*/}/*读入函数,参数为结构体数组*//* int load(ADDRESS t[]) *//* { *//* int i,n; *//* FILE *fp; *//*指向文件的指针*//* if((fp=fopen("record.txt","rb"))==NULL)*//* 打开文件*//* { *//* printf("can not open file\n"); *//*不能打开*//* exit(1); *//*退出*//* } *//* fscanf(fp,"%d",&n);*/ /*读入记录数*//* for(i=0;i<n;i++) *//* fscanf(fp,"%20s%30s%10s",t[i].name,t[i].units,t[i].tele); */ /*按格式读入记录*//* fclose(fp);*/ /*关闭文件*//* printf("You have success read data from file\n"); *//* 显示保存成功*/ /* return n;*/ /*返回记录数*//* } *//*按序号显示记录函数*/int modify_kucun(ADDRESS t[],int n){char s[20],ch[10]; /*保存待查找姓名字符串*/int i,j; /*保存查找到结点的序号*//*clrscr(); */printf("please input the cloth name which you wanted to modify its kucun:\n");scanf("%s",s); /*输入待查找姓名*/i=find(t,n,s); /*调用find函数,得到一个整数*/if(i>n-1) /*如果整数i值大于n-1,说明没找到*/printf("sorry!the name don't exist!\n");else{print(t[i]); /*找到,调用显示函数显示记录*//*printf("Are you sure to modify its kucun?Yes--y/"); */printf("please input the new kucun you want:\n");scanf("%c",ch);for(j=0;j<10;j++)t[i].kucun[j]=ch[j];printf("Ok!the kucun has been modified!");}clrscr();}void display(ADDRESS t[]){int id,n;FILE *fp; /*指向文件的指针*/if((fp=fopen("record.txt","rb"))==NULL) /*打开文件*/{printf("can not open file\n"); /*不能打开文件*/exit(1); /*退出*/}printf("Enter order number:\n"); /*显示信息*/scanf("%d",&id); /*输入序号*/fscanf(fp,"%d",&n); /*从文件读入记录数*/if(id>=0&&id<n) /*判断序号是否在记录范围内*/{fseek(fp,(id-1)*sizeof(ADDRESS),1); /*移动文件指针到该记录位置*/print(t[id]); /*调用输出函数显示该记录*/printf("\r\n");}elseprintf("no %d number record\n ",id); /*如果序号不合理显示信息*/fclose(fp); /*关闭文件*/}/*排序函数,参数为结构体数组和记录数*/void sort(ADDRESS t[],int n){int i,j,flag;char y;ADDRESS temp; /*临时变量做交换数据用*/R: printf("Please select which kind to sort!0--sort by kucun/1--sort by Chu_Chang_Ri_Qi\n "); /*选择何种方式排序*/if(getch()=='0'){for(i=0;i<n;i++){flag=0; /*设标志判断是否发生过交换*/for(j=0;j<n-1;j++)if((strcmp(t[j].kucun,t[j+1].kucun))>0) /*比较大小*/{flag=1;strcpy(,t[j].name); /*交换记录*/strcpy(temp.units,t[j].units);strcpy(temp.tele,t[j].tele);strcpy(temp.product_company,t[j].product_company);strcpy(temp.designer,t[j].designer);strcpy(temp.price,t[j].price);strcpy(temp.kucun,t[j].kucun);strcpy(temp.year,t[j].year);strcpy(temp.month,t[j].month);strcpy(temp.day,t[j].day);strcpy(t[j].name,t[j+1].name);strcpy(t[j].units,t[j+1].units);strcpy(t[j].tele,t[j+1].tele);strcpy(t[j].product_company,t[j+1].product_company);strcpy(t[j].designer,t[j+1].designer);strcpy(t[j].price,t[j+1].price);strcpy(t[j].kucun,t[j+1].kucun);strcpy(t[j].year,t[j+1].year);strcpy(t[j].month,t[j+1].month);strcpy(t[j].day,t[j+1].day);strcpy(t[j+1].name,);strcpy(t[j+1].units,temp.units);strcpy(t[j+1].tele,temp.tele);strcpy(t[j+1].product_company,temp.product_company);strcpy(t[j+1].designer,temp.designer);strcpy(t[j+1].price,temp.price);strcpy(t[j+1].kucun,temp.kucun);strcpy(t[j+1].year,temp.year);strcpy(t[j+1].month,temp.month);strcpy(t[j+1].day,temp.day);}if(flag==0) break; /*如果标志为0,说明没有发生过交换循环结束*/}printf("sort sucess\n"); /*显示排序成功*/}elseif(getch()=='1'){for(i=0;i<n;i++){flag=0; /*设标志判断是否发生过交换*/for(j=0;j<n-1;j++)/* if((()&&((strcmp(t[j].month,t[j+1].month))>0)))&&((strcmp(t[j].day,t[j+1].day))>0))||(((strcmp(t[j].year,t[j+1].year))=0)&&((strcmp(t[j].month,t[j+1].month))>0))||(((strcmp(t[j].year,t[j+1].year))=0)&&((strcmp(t[j].month,t[j+1].month))=0)&&((st rcmp(t[j].day,t[j+1].day))>0))) *//*比较大小*/if(( ((strcmp(t[j].year,t[j+1].year))>0)&&((strcmp(t[j].month,t[j+1].month))>0)&&( (strcmp(t[j].day,t[j+1].day))>0) )||( ((strcmp(t[j].year,t[j+1].year))==0)&&((strcmp(t[j].month,t[j+1].month))>0) )||( ((strcmp(t[j].year,t[j+1].year))==0)&&((strcmp(t[j].month,t[j+1].month))==0)&& ((strcmp(t[j].day,t[j+1].day))>0) )){flag=1;strcpy(,t[j].name); /*交换记录*/。

C语言课程设计——家庭财务管理系统

C语言课程设计——家庭财务管理系统

时间:二O二一年七月二十九日课程设计陈说之阿布丰王创作课程设计题目:家庭财政管理系统学生姓名:专业:信息工程班级:指导教师:2018年 1月 8日1.需求分析根据家庭账务管理的需要,建立一个“家庭账务管理系统”,以方便对家庭日常收入及支出进行记录和管理.该系统要求:①家庭月收入管理②家庭月支出管理③统计家庭总收入/总支出④系统提供收入/支出的添加、删除和修改功能.2. 总体设计根据以上分析,本家庭账务管理系统主要包括:①从键盘键入家庭月收入、月支出数据;②查询月收入、月支出明细;③删除收入、支出数据;④修改收入、支出数据;⑤统计总收入/总支出;⑥退出系统.除main()函数之外,系统还界说了以下函数来实现各部份内容:①add_income():添加收入数据函数.②add_payout():添加支出数据函数.③search_data():查找数据函数.④initialize():初始化函数,读取文本数据.⑤show_info():显示数据函数.⑥count_total():统计函数,统计总收入、总支出.⑦update_data():修改信息函数.⑧delete_data():删除数据函数.⑨quit():退出函数.法式结构功能图如下:3.详细设计3.1收入管理3.2支出管理4.测试结果4.1 法式运行主菜单4.2 添加收入测试4.3 查询收入明细测试4.4 删除收入测试4.5 修改收入测试4.6 添加支出测试4.7 查询支出明细测试4.8 删除支出测试4.9 修改支出测试4.10 统计总收入/支出测试4.11 退出系统测试5.软件把持使用说明书本系统采纳命令行对话方式进行把持,运行后呈现主界面(如下图所示),然后依照主界面菜单指引把持即可.6.总结编写法式之前要有一个整体的思路,不能写到哪里算哪里.这样很容易遗漏,连续性也欠好.通过本次的课程设计让我对数组、文件的寄存、循环结构等知识有了更加透彻的理解.希望在以后的课程设计中对知识的运用能够更加的熟练.代码:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>#define MAXNAME 11 //家庭成员姓名的最年夜长度#define MAXDETAIL 21 //注最年夜长度//自界说枚举类型fi_type,用来暗示收入与支出typedef enum _fi_type{income=1,//收入payout =-1 //支出} fi_type;// 家庭财政信息结构体typedef struct _fi_info{int year;int month;fi_type type;char name[9];float money;char detail[11];}fi_info;// 存储财政数据结构的结构体typedef struct _fi_data{fi_info info;struct _fi_data* next;} fi_data;fi_data *head;//财政数据的头结点 void menu();//菜单函数void add_income();void search_income();void delete_income();void update_income();void add_payout();void search_payout();void delete_payout();void update_payout();void count_total();void quit();//void search_data(fi_type type);void delete_data(fi_type type);void update_data(fi_type type);//void initialize();void save_to_file();void clear_data();fi_data *get_last();fi_data *get_previous(fi_data *p); void input_info(fi_info *info);void show_info(fi_data *p);void menu(){printf("\n");printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t\t\t 家庭财政管理系统\n");printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t*******************************************\n ");printf("\t\t收入管理:");printf("1.添加收入");printf(" 2.查询收入明细\n");printf("\t\t\t 3.删除收入");printf(" 4.修改收入\n");printf("\t\t*******************************************\n ");printf("\t\t支出管理:");printf("5.添加支出");printf(" 6.查询支出明细\n");printf("\t\t\t 7.删除支出");printf(" 8.修改支出\n");printf("\t\t*******************************************\n ");printf("\t\t统计:");printf("9.统计总收入/总支出\n");printf("\t\t*******************************************\n ");printf("\t\t退出:0.退出系统\n");printf("\t\t*******************************************\n \n\n");}void main(){int selected=0;initialize();while(selected>=0&&selected<=9){system("cls");menu();printf("\t\t>请选择要进行的把持(0-9):");if(scanf("%d",&selected)!=1||selected<0||selected>9){printf("\t\t>输入有误!请选择(0-9)之间的数字!按任意键重试");getchar();}else{switch(selected){case 0:exit(0);clear_data();break;case 1:add_income();save_to_file();break;case 2:search_income();break;case 3:delete_income();save_to_file();break; case 4:update_income();save_to_file();break; case 5:add_payout();save_to_file();break;case 6:search_payout();break;case 7:delete_payout();save_to_file();break; case 8:update_payout();save_to_file();break;case 9:count_total();break;}}}}void add_income()//添加收入{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=income;if(head==NULL)head=p;elseget_last()->next=p;}void add_payout()//添加支出{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=payout;if(head==NULL)head=p;elseget_last()->next=p;}//输入函数void input_info(fi_info *info){printf("\t\t>请输入年月(YYYY/M)");scanf("%d/%d",&(info->year),&(info->month)); printf("\t\t>请输入家庭成员姓名(最年夜长度为%d):",MAXNAME-1);scanf("%s",info->name);printf("\t\t>输入金额:");scanf("%f",&(info->money));printf("\t\t>请输入备注(最年夜长度为%d):",20); scanf("%s",info->detail);}//查找数据函数void search_data(fi_type type){int year=0;int month=0;fi_data *p=NULL;int count=0;char input=' ';while(1){printf("\t\t>请输入要查询的年月(YYYY/M)");if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){show_info(p);system("PAUSE");count++;}p=p->next;}if(count==0){printf("\t\t>没有找到数据\n");}printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}//初始化函数,读取文本数据void initialize(){FILE * fp=NULL;fi_data *p=NULL;fi_data *last=NULL;int count=0;fp=fopen("data.txt","rb");if(fp==NULL){fp=fopen("data.txt","w");fclose(fp);return;}p=(fi_data*)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;while(fread(&(p->info),sizeof(fi_info),1,fp)==1) {if(head==NULL)head=p;else{last=get_last();last->next=p;}count++;fseek(fp,count*sizeof(fi_info),SEEK_SET);p=(fi_data *)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;}free(p);p=NULL;fclose(fp);}//显示信息函数void show_info(fi_data *p){int i=0;printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");printf("|NO.\t |年/月\t\t|类型\t\t|姓名\t\t|金额\t\t|备注\t\t|\n");printf("|%5d\t|%4d/%02d\t|%4s\t|%10s\t|%10.2f|%20s|\n",i+ 1,p->info.year,p->info.month,p->info.type==income?"收入":"支出",p->,p->info.money,p->info.detail);printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");}//统计总收入、总支出void count_total(){float total_income=0.0;float total_payout=0.0;fi_data *p=head;while(p!=NULL){if(p->info.type==income){total_income+=p->info.money;}else{total_payout+=p->info.money;}p=p->next;}printf("\t\t+\t\t+\t\t+\n");printf("\t\t|合计收入\t|合计支出\t|结余\t|\n");printf("\t\t%12.2f|%12.2f|%12.2f|\n",total_income,total_p ayout,total_income-total_payout);printf("\t\t+\t\t+\t\t+\n");printf("\t\t>按任意键返回主菜单");getchar();getchar();}//保管到文件void save_to_file(){FILE *fp=fopen("data.txt","wb" );fi_data *p=head;while(p!=NULL){fwrite(&(p->info),sizeof(fi_info),1,fp);fseek(fp,0,SEEK_END);p=p->next;}fclose(fp);}//修改信息函数void update_data(fi_type type){ int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;char input;int count=0;int i=0;while(1){ printf("\t\t>请输入要查询的年月(YYYY/M)");if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);input_info(&(p->info));printf("\t\t修改胜利\n");p=get_previous(p);}p=p->next;}if(count==0)printf("\t\t>没有找到数据\n");printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void delete_data(fi_type type)//删除数据函数 {int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;int count=0;char input=' ';int i=0;while(1){ printf("\t\t>请输入要查询的年月(YYYY/M)");if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);pre=get_previous(p);if(pre==NULL)head=head->next;elsepre->next=p->next;free(p);printf("\t\t>删除胜利\n");}p=p->next;}if(count==0)printf("\t\t>没有找到数据\n");printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void clear_data()//清空链表数据{fi_data *p=NULL;while(head!=NULL){if(head->next!=NULL){p=head;head=head->next;free(p);p=NULL;}else{free(head);head=NULL;}}}fi_data *get_last() {fi_data * p=head;if(p==NULL)return p;while((p!=NULL)&&(p->next!=NULL)) p=p->next;return p;}fi_data *get_previous(fi_data *p) {fi_data *previous=head;while(previous!=NULL){if(previous->next==p)break;previous=previous->next;}return previous;}void search_payout(){search_data(payout);}void delete_payout() {delete_data(payout); }void update_payout() {update_data(payout); }void search_income() {search_data(income); }void delete_income() {delete_data(income); }void update_income() {update_data(income); }。

家庭财务管理系统C

家庭财务管理系统C

目录一、需求分析 (1)二、程序的主要功能 (2)三、程序运行平台 (3)四、系统总框架图 (4)五、程序类的说明 (5)六、模块分析 (6)七、比较有特色的函数 (7)八、存在的不足与对策 (8)一、需求分析家庭财务收支管理是一个家庭日常生活中不可缺少一部分,也是财务管理的重要组成部分。

它的内容对于财务管理者来说都至关重要,设计一个程序对财务收支进行管理是必不可少的。

二、程序的主要功能1、用户管理:对账单的用户进行登记。

2、消费明细:对用户账单明细进行记录。

3、个人账单查询:对用户的账单进行查询。

4、账单总计:对整个系统所存账单进行总计。

5、显示所有用户账单:把所有账单进行显示。

三、程序运行平台Dev c++四、系统总框架图五、程序类的说明class inter_f //定义一个界面类{public:inter_f(){}; //构造~inter_f(){}; //析构void display(); //声明显示用户信息界面函数/////////////////// void check(user* p); //声明用户登记函数void seek(user* p); //声明用户查询函数void show(user* p); //声明显示用户信息函数void add(user* p); //声明用户新增函数void cancel(user* p); //声明用户注销函数void exit(); //声明用户退出函数void limit(user& ru); //声明用户操作界面函数void display2(); //消费明细界面函数///////////////////////void water_cost(user* p); //水费函数void elec_cost(user* p); //电费函数void comm_cost(user* p); //通信费函数void shop_cost(user* p); //购物费函数void gas_cost(user* p); //煤气费函数void pin_cost(user* p); //零用函数void exit2(); //声明退出消费明细函数void limit2(user& ru); //声明消费明细操作界面函数void display1(); //声明显示总信息界面//////////////////////void personal_bill(user* p); //声明个人账单函数void amount_bill(user* p); //账单总计函数void show1(user* p); //声明显示所有用户账务函数void exit1(); //声明财务退出函数void limit1(user& ru); ////总界面函数};六、模块分析1、用户管理:对账单的用户进行登记。

家庭财务管理系统(多文件版)

家庭财务管理系统(多文件版)
scanf("%d%d",&year,&month);
for(i=0;i<m;i++)
if(strcmp(inf[i].name,name) == 0 && inf[i].year == year && inf[i].month == month)
{
g=i;
h=1;
if(k==1)
{
for(i=0;i<n;i++)
if(strcmp(peo[i].username,name)==0)
{
g=i;
p=1;
break;
}
if(p==1)
{
n=h-1;
fp=fopen("memberlist.txt","w");
int year; //年份
int month; //月份
int income; //收入
int output; //支出
}inf[MAX_INF];
int n,m; //全局变量 n为文件中家庭成员实际容量 m为文件中收支信息实际容量
#define FINANCE_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#define MAX_PEO 2000 //定义家庭成员最大人数
printf(" 1. 浏览家庭成员信息 2. 修改家庭成员收支信息\n");

C语言程序设计个人财务管理系统

C语言程序设计个人财务管理系统

C语言程序设计个人财务管理系统个人财务管理系统是一款帮助个人进行财务管理和分析的软件,能够帮助用户记录、分类、统计和分析个人的收入和支出。

本文将介绍一个使用C语言编写的简单个人财务管理系统。

首先,我们需要定义几个结构体来表示财务记录和分类信息:```c//定义财务记录结构体struct financial_recordint id; // 编号int year; // 年份int month; // 月份int day; // 日期char type[20]; // 类型double amount; // 金额};//定义分类信息结构体struct categorychar name[20]; // 分类名称double total; // 总金额int count; // 记录数量};//定义财务管理系统结构体struct financial_management_systemstruct financial_record records[100]; // 财务记录数组struct category categories[10]; // 分类信息数组int record_count; // 记录数量};```接下来,我们可以实现几个基本的功能,如添加记录、删除记录、查询记录和分类汇总等:```c//添加财务记录void add_record(struct financial_management_system *system) printf("请输入年份:");scanf("%d", &(system->records[system->record_count].year));//省略其他输入信息的代码printf("请输入金额:");scanf("%lf", &(system->records[system->record_count].amount));system->record_count++;//删除财务记录void delete_record(struct financial_management_system*system, int id)for (int i = 0; i < system->record_count; i++)if (system->records[i].id == id)for (int j = i; j < system->record_count - 1; j++)system->records[j] = system->records[j + 1];}system->record_count--;break;}}//查询财务记录void query_record(struct financial_management_system system, int year, int month, int day)for (int i = 0; i < system.record_count; i++)if (system.records[i].year == year &&system.records[i].month == month &&system.records[i].day == day)printf("编号:%d\n", system.records[i].id);//输出其他信息的代码}}//分类汇总void summarize_category(struct financial_management_system system)for (int i = 0; i < system.record_count; i++)//查找分类信息是否存在int category_index = -1;for (int j = 0; j < 10; j++)if (strcmp(system.records[i].type, system.categories[j].name) == 0)category_index = j;break;}}//如果分类信息不存在,则添加分类信息if (category_index == -1)strcpy(system.categories[system.category_count].name, system.records[i].type);system.categories[system.category_count].count = 1;system.categories[system.category_count].total = system.records[i].amount;system.category_count++;} elsesystem.categories[category_index].count++;system.categories[category_index].total +=system.records[i].amount;}}for (int i = 0; i < system.category_count; i++)printf("分类:%s\t总金额:%lf\t记录数量:%d\n",system.categories[i].name,system.categories[i].total,system.categories[i].count);}```最后,我们可以编写主函数来完成用户和系统的交互:```cint maistruct financial_management_system system; system.record_count = 0;system.category_count = 0;while (1)printf("\n请选择操作:\n");printf("1. 添加记录\n");printf("2. 删除记录\n");printf("3. 查询记录\n");printf("4. 分类汇总\n");printf("0. 退出\n");int choice;scanf("%d", &choice);switch (choice)case 1:add_record(&system);break;case 2:printf("请输入要删除的记录编号:");int id;scanf("%d", &id);delete_record(&system, id);break;case 3:printf("请输入查询的日期(年月日):"); int year, month, day;scanf("%d %d %d", &year, &month, &day); query_record(system, year, month, day); break;case 4:summarize_category(system);break;case 0:return 0;default:printf("无效的操作!\n");break;}}```通过以上代码,我们实现了一个简单的个人财务管理系统。

C语言课程设计——家庭财务管理系统

C语言课程设计——家庭财务管理系统

FILE *fp;
int i;
if((fp=fopen("peoplelist4。txt”,"r"))!=NULL)

fscanf(fp,”%d\n",&n);
for(i=0;i〈n;i++)
fscanf(fp,"%s%s%s\n",peo[i]。username,peo[i].code,peo[i]。flag);

fprintf(fp,”%d\n",n);
for(i=0;i<n;i++)
fprintf(fp,"%s %s %s\n”,peo[i]。username,peo[i].code,peo[i].flag);

fclose(fp);
fp=fopen("thinglist4。txt”,"w");

fprintf(fp,”%d\n”,m);
for(i=0;i〈m;i++)
fprintf(fp,"%s %d %d %d %d\n",thi[i]。name,thi[i].year,thi[i].month,thi[i].income,thi[i].output);

fclose(fp);
return 0;
}
int carry() //将数据从文件中读出
fprintf(fp,”%s %d %d %d %d\n”,thi[i]。name,thi[i].year,thi[i].month,thi[i].income,thi[i].output);
fclose(fp);
printf(”\n······\n删除成功。\n”);

C语言课程设计——家庭财务管理系统

C语言课程设计——家庭财务管理系统

课程设计陈述之袁州冬雪创作课程设计题目:家庭财务管理系统学生姓名:专业:信息工程班级:指导教员:2018年 1月 8日1.需求分析根据家庭账务管理的需要,建立一个“家庭账务管理系统”,以方便对家庭日常收入及支出停止记录和管理.该系统要求:①家庭月收入管理②家庭月支出管理③统计家庭总收入/总支出④系统提供收入/支出的添加、删除和修改功能.2. 总体设计根据以上分析,本家庭账务管理系统主要包含:①从键盘键入家庭月收入、月支出数据;②查询月收入、月支出明细;③删除收入、支出数据;④修改收入、支出数据;⑤统计总收入/总支出;⑥退出系统.除main()函数之外,系统还定义了以下函数来实现各部分内容:①add_income():添加收入数据函数.②add_payout():添加支出数据函数.③search_data():查找数据函数.④initialize():初始化函数,读取文本数据.⑤show_info():显示数据函数.⑥count_total():统计函数,统计总收入、总支出.⑦update_data():修改信息函数.⑧delete_data():删除数据函数.⑨quit():退出函数.程序布局功能图如下:3.详细设计4.测试成果4.1 程序运行主菜单4.2 添加收入测试4.3 查询收入明细测试4.4 删除收入测试4.5 修改收入测试4.6 添加支出测试4.7 查询支出明细测试4.8 删除支出测试4.9 修改支出测试4.10 统计总收入/支出测试4.11 退出系统测试5.软件操纵使用说明书本系统采取饬令行对话方式停止操纵,运行后出现主界面(如下图所示),然后依照主界面菜单指引操纵即可.编写程序之前要有一个整体的思路,不克不及写到哪里算哪里.这样很容易遗漏,持续性也欠好.通过本次的课程设计让我对于数组、文件的存放、循环布局等知识有了更加透彻的懂得.希望在以后的课程设计中对于知识的运用可以更加的熟练.代码:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>#define MAXNAME 11 //家庭成员姓名的最大长度#define MAXDETAIL 21 //注最大长度//自定义列举类型fi_type,用来暗示收入与支出typedef enum _fi_type{income=1,//收入payout =-1 //支出} fi_type;// 家庭财务信息布局体typedef struct _fi_info{int year;int month;fi_type type;char name[9];float money;char detail[11];}fi_info;// 存储财务数据布局的布局体typedef struct _fi_data{fi_info info;struct _fi_data* next;} fi_data;fi_data *head;//财务数据的头结点 void menu();//菜单函数void add_income();void search_income();void delete_income();void update_income();void add_payout();void search_payout();void delete_payout();void update_payout();void count_total();void quit();//void search_data(fi_type type);void delete_data(fi_type type);void update_data(fi_type type);//void initialize();void save_to_file();void clear_data();fi_data *get_last();fi_data *get_previous(fi_data *p); void input_info(fi_info *info);void show_info(fi_data *p);void menu(){printf("\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t\t 家庭财务管理系统\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t*************************************** ****\n");printf("\t\t收入管理:");printf("1.添加收入");printf(" 2.查询收入明细\n");printf("\t\t\t 3.删除收入");printf(" 4.修改收入\n");printf("\t\t*************************************** ****\n");printf("\t\t支出管理:");printf("5.添加支出");printf(" 6.查询支出明细\n");printf("\t\t\t 7.删除支出");printf(" 8.修改支出\n");printf("\t\t*************************************** ****\n");printf("\t\t统计:");printf("9.统计总收入/总支出\n");printf("\t\t*************************************** ****\n");printf("\t\t退出:0.退出系统\n");printf("\t\t*************************************** ****\n\n\n");}void main(){int selected=0;initialize();while(selected>=0&&selected<=9){system("cls");menu();printf("\t\t>请选择要停止的操纵(0-9):");if(scanf("%d",&selected)!=1||selected<0||selected>9) {printf("\t\t>输入有误!请选择(0-9)之间的数字!按任意键重试");getchar();}else{switch(selected){case 0:exit(0);clear_data();break;case 1:add_income();save_to_file();break; case 2:search_income();break;case3:delete_income();save_to_file();break;case4:update_income();save_to_file();break;case 5:add_payout();save_to_file();break;case 6:search_payout();break;case7:delete_payout();save_to_file();break;case8:update_payout();save_to_file();break;case 9:count_total();break;}}}}void add_income()//添加收入{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=income;if(head==NULL)head=p;elseget_last()->next=p;}void add_payout()//添加支出{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=payout;if(head==NULL)head=p;elseget_last()->next=p;}//输入函数void input_info(fi_info *info){printf("\t\t>请输入年代(YYYY/M)");scanf("%d/%d",&(info->year),&(info->month));printf("\t\t>请输入家庭成员姓名(最大长度为%d):",MAXNAME-1);scanf("%s",info->name);printf("\t\t>输入金额:");scanf("%f",&(info->money));printf("\t\t>请输入备注(最大长度为%d):",20);scanf("%s",info->detail);}//查找数据函数void search_data(fi_type type){int year=0;int month=0;fi_data *p=NULL;int count=0;char input=' ';while(1){printf("\t\t>请输入要查询的年代(YYYY/M)"); if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){show_info(p);system("PAUSE");count++;}p=p->next;}if(count==0){printf("\t\t>没有找到数据\n");}printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}//初始化函数,读取文本数据void initialize(){FILE * fp=NULL;fi_data *p=NULL;fi_data *last=NULL;int count=0;fp=fopen("data.txt","rb");if(fp==NULL){fp=fopen("data.txt","w");fclose(fp);return;}p=(fi_data*)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;while(fread(&(p->info),sizeof(fi_info),1,fp)==1) {if(head==NULL)head=p;else{last=get_last();last->next=p;}count++;fseek(fp,count*sizeof(fi_info),SEEK_SET);p=(fi_data *)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;}free(p);p=NULL;fclose(fp);}//显示信息函数void show_info(fi_data *p){int i=0;printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");printf("|NO.\t |年/月\t\t|类型\t\t|姓名\t\t|金额\t\t|备注\t\t|\n");printf("|%5d\t|%4d/%02d\t|%4s\t|%10s\t|%10.2f|%20s| \n",i+1,p->info.year,p->info.month,p->info.type==income?"收入":"支出",p->,p->info.money,p->info.detail);printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");}//统计总收入、总支出void count_total(){float total_income=0.0;float total_payout=0.0;fi_data *p=head;while(p!=NULL){if(p->info.type==income){total_income+=p->info.money;}else{total_payout+=p->info.money;}p=p->next;}printf("\t\t+\t\t+\t\t+\n");printf("\t\t|合计收入\t|合计支出\t|节余\t|\n");printf("\t\t%12.2f|%12.2f|%12.2f|\n",total_income,t otal_payout,total_income-total_payout);printf("\t\t+\t\t+\t\t+\n");printf("\t\t>按任意键返回主菜单");getchar();getchar();}//保管到文件void save_to_file(){FILE *fp=fopen("data.txt","wb" );fi_data *p=head;while(p!=NULL){fwrite(&(p->info),sizeof(fi_info),1,fp);fseek(fp,0,SEEK_END);p=p->next;}fclose(fp);}//修改信息函数void update_data(fi_type type){ int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;char input;int count=0;int i=0;while(1){ printf("\t\t>请输入要查询的年代(YYYY/M)"); if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);input_info(&(p->info));printf("\t\t修改成功\n");p=get_previous(p);}p=p->next;}if(count==0)printf("\t\t>没有找到数据\n");printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void delete_data(fi_type type)//删除数据函数 {int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;int count=0;char input=' ';int i=0;while(1){ printf("\t\t>请输入要查询的年代(YYYY/M)"); if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);pre=get_previous(p);if(pre==NULL)head=head->next;elsepre->next=p->next;free(p);printf("\t\t>删除成功\n");}p=p->next;}if(count==0)printf("\t\t>没有找到数据\n");printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void clear_data()//清空链表数据 {fi_data *p=NULL;while(head!=NULL){if(head->next!=NULL){p=head;head=head->next;free(p);p=NULL;}else{free(head);head=NULL;}}fi_data *get_last() {fi_data * p=head;if(p==NULL)return p;while((p!=NULL)&&(p->next!=NULL))p=p->next;return p;}fi_data *get_previous(fi_data *p){fi_data *previous=head;while(previous!=NULL){if(previous->next==p)break;previous=previous->next;}return previous;void search_payout() {search_data(payout); }void delete_payout() {delete_data(payout); }void update_payout() {update_data(payout); }void search_income() {search_data(income); }void delete_income() {delete_data(income); }void update_income()update_data(income); }。

家庭财务管理系统

家庭财务管理系统

//家庭财务管理系统,本程序扩充至一个小型的集体。

由于水平有限不能调用数据库信息不能永久保存,正在致力于研究!//实现家庭的各种账单(水/电/煤气费,宽带/电话费等)的管理功能,//可以对各类账单及用户信息进行登记、修改、删除等。

#include<iostream>using namespace std;#include<string>#define error 0int cost_n=-1;const int M=100; //给系统设定人数限制class cost //费用类,定义抽象类,虚函数{public:double *s; //费用成员指针virtual int get_n()=0; //定义一个费用总个数虚函数virtual double get_cost()=0; //定义计算费用的虚函数cost(){s=new double[M];for(int i=0;i<M;i++){s[i]=0.0;}}virtual ~cost(){delete[] s;}};class water_rate:public cost //水费类继承费用类{public:double *t; //用水量int nT; //用户用水个数water_rate(); //构造函数~water_rate(); //析构函数void set(); //输入信息函数void set_water(); //显示水费函数int get_n(); //返回用户水费个数函数double get_cost(); //返回用户用水总费用函数};water_rate::water_rate() //给费用和用水量分配空间{nT=0;t=new double[M];for(int i=0;i<M;i++){t[i]=0.0;}}water_rate::~water_rate(){delete[] t;}void water_rate::set() //计算用户的水费{cout<<"\t请输入用水量(吨):注(1.95元/吨)"<<endl;cin>>t[cost_n];nT++;}void water_rate::set_water(){s[cost_n]=t[cost_n]*1.95;cout<<"水费:\t\t"<<"(1.95元/吨)\t\t"<<t[cost_n]<<"*1.95="<<s[cost_n]<<"元"<<endl; }int water_rate::get_n() //返回用户水费个数函数{return nT;}double water_rate::get_cost() //返回用户用水费总数用函数{double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}class elec_rate:public cost //电费类继承费用类{public:double *d;int nT; //计算用电的用户个数elec_rate(); //电费类的构造~elec_rate(); //析构void set(); //输入用电度数函数void set_elec();//显示电费信息int get_n(); //返回用户电费费个数函数double get_cost(); //返回用户用电总费用函数};elec_rate::elec_rate(){nT=0;d=new double[M];for(int i=0;i<M;i++){d[i]=0.0;}}elec_rate::~elec_rate(){delete[] d;}void elec_rate::set(){cout<<"\t请输入用电度数:注(0.65元/度)"<<endl;cin>>d[cost_n];nT++;}void elec_rate::set_elec() //计算电费函数{s[cost_n]=d[cost_n]*0.65;cout<<"电费:\t\t"<<"(0.65元/度)\t\t"<<d[cost_n]<<"*0.65="<<s[cost_n]<<"元"<<endl; }int elec_rate::get_n() //返回用户电费费个数函数{return nT;}double elec_rate::get_cost() //返回用户用电总费用函数{double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//电费类定义完毕!class comm_rate:public cost //定义一个通信类函数{public:double *tp; //定义一个电话费用函数double *cp; //定义一个上网费用函数int nT; //计算通信用户个数comm_rate(); //通信类构造~comm_rate();//通信类析构void set(); //输入电话用和上网费用void set_comm(); //计算通信费用int get_n();double get_cost(); //计算通信总费用};comm_rate::comm_rate(){nT=0;tp=new double[M];cp=new double[M];for(int i=0;i<M;i++){tp[i]=0.0;cp[i]=0.0;}}comm_rate::~comm_rate(){delete[] tp;delete[] cp;}void comm_rate::set(){cout<<"请输入通信消费:注(元)"<<endl;cout<<"电话消费上网消费:"<<endl;cin>>tp[cost_n]>>cp[cost_n];nT++;}void comm_rate::set_comm(){s[cost_n]=tp[cost_n]+cp[cost_n];cout<<"通信费:\t\t"<<"(电话费+上网费)\t\t"<<tp[cost_n]<<"+"<<cp[cost_n]<<"="<<s[cost_n]<<"元"<<endl;}int comm_rate::get_n(){return nT;}double comm_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}///通信类定义完毕!class shop_rate:public cost //定义一个购物类{public:double *sp; //衣服费用成员double *hp; //其他用品费用成员int nT; //计算购物用户个数shop_rate(); //购物类构造~shop_rate(); //析构void set(); //输入购物费用void set_shop(); //计算购物费用int get_n(); //返回购物用户个数double get_cost(); //返回购物总消费};shop_rate::shop_rate(){nT=0;sp=new double[M];hp=new double[M];for(int i=0;i<M;i++){sp[i]=0.0;hp[i]=0.0;}}shop_rate::~shop_rate(){delete[] sp;delete[] hp;}void shop_rate::set(){cout<<"请输入购物消费:(元)"<<endl;cout<<"衣服消费其他用品消费:"<<endl;cin>>sp[cost_n]>>hp[cost_n];nT++;}void shop_rate::set_shop(){s[cost_n]=sp[cost_n]+hp[cost_n];cout<<"购物费用:\t"<<"(衣服+其他用品)\t\t"<<sp[cost_n]<<"+"<<hp[cost_n]<<"="<<s[cost_n]<<"元"<<endl;}int shop_rate::get_n(){return nT;}double shop_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//购物类定义完毕!class gas_rate:public cost //定义一个煤气费类{public:double *g;int nT; //计算用煤气用户的个数gas_rate(); //构造~gas_rate(); //析构void set(); //输入煤气用量void set_gas(); //计算煤气费用int get_n(); //返回煤气用户个数double get_cost(); //返回煤气总费用};gas_rate::gas_rate(){nT=0;g=new double[M];for(int i=0;i<M;i++){g[i]=0.0;}}gas_rate::~gas_rate(){delete[] g;}void gas_rate::set(){cout<<"请输入煤气用量(立方米):注(2.05元/立方米)"<<endl;cin>>g[cost_n];nT++;}void gas_rate::set_gas(){s[cost_n]=g[cost_n]*2.05;cout<<"煤气费用:\t"<<"(2.05元/立方米)\t\t"<<g[cost_n]<<"*2.05="<<s[cost_n]<<"元"<<endl;}int gas_rate::get_n(){return nT;}double gas_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//煤气费用类定义完毕!class pin_rate:public cost //定义一个零用费类{public:double *pc; //定义一个吃饭费用成员double *pa; //定义一个其他成员int nT; //计算用户零用个数pin_rate(); //构造~pin_rate(); //析构void set(); //输入吃饭费用,其他费用函数void set_pin(); //显示零用费用int get_n(); //返回用户零用个数double get_cost(); //返回用户的零用总费用};pin_rate::pin_rate(){nT=0;pc=new double[M];pa=new double[M];for(int i=0;i<M;i++){pc[i]=0.0;pa[i]=0.0;}}pin_rate::~pin_rate(){delete[] pc;delete[] pa;}void pin_rate::set(){cout<<"请输入零用花费:"<<endl;cout<<"吃饭费用: 其他费用:"<<endl;cin>>pc[cost_n]>>pa[cost_n];nT++;}void pin_rate::set_pin(){s[cost_n]=pc[cost_n]+pa[cost_n];cout<<"零用花费:\t"<<"(吃饭+其他)\t\t"<<pc[cost_n]<<"+"<<pa[cost_n]<<"="<<s[cost_n]<<"元"<<endl;}int pin_rate::get_n(){return nT;}double pin_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//零用费用类定义完毕!class user{int *a; //用户的户号string *name; //用户姓名string *tel; //用户电话public:water_rate water_c; //定义一个水费类对象elec_rate elec_c; //定义一个电费类对象comm_rate comm_c; //定义一个通信费类对象shop_rate shop_c; //定义一个购物类对象gas_rate gas_c; //定义一个煤气费用类对象pin_rate pin_c; //定义一个零用费用类对象int N; //统计用户个数void set(int m); //初始化函数void inquire(); //查询用户函数int inquire1(); //查询用户水费函数void show(); //显示用户函数void show1(); //显示用户及费用函数void add(); //添加数据成员函数void cancel(); //删除函数double amount(int m); //一个用户的费用总计double all_amount(); //所有用户的所有账单总计};void user::set(int m) //初始化定义用户信息{N=m;a=new int[M];name=new string[M];tel=new string[M];for(int i=0;i<N;i++){cin>>name[i]>>tel[i];a[i]=i+1;}}void user::inquire() //类内部查询函数{cout<<"\t请输入要查找的用户名:"<<endl;string s;cin>>s;int j=0;for(int i=0;i<N;i++){if(s==name[i]){cout<<"用户编号:"<<a[i]<<" "<<" 用户名:"<<name[i]<<" "<<"电话号码:"<<tel[i]<<endl;j++;}}if(j==0){cout<<"用户不存在!"<<endl;}}int user::inquire1() //类内部查询用户水费清单函数{cout<<"\t请用户输入用户编号用户名:(如忘记可在用户管理里面查询!)"<<endl;cout<<"用户编号用户名:"<<endl;int n;string s;cin>>n>>s;int j=0;for(int i=0;i<N;i++){if(n==a[i]&&s==name[i]){cout<<"用户编号:"<<a[i]<<" "<<" 用户名:"<<name[i]<<" "<<"电话号码:"<<tel[i]<<endl;cost_n=i;j++;break;}}if(j==0){cout<<"用户不存在!"<<endl;}return cost_n;}void user::show() //类内部显示函数{cout<<"用户编号: 用户名: 电话号码:"<<endl;for(int i=0;i<N;i++){cout<<a[i]<<"\t"<<name[i]<<"\t"<<tel[i]<<endl;}}void user::show1(){cout<<"============================================================ =================="<<endl;cout<<"用户编号: 用户名: 电话: 水费: 电费: 通信费: 购物: 煤气费: 零用费: 总计:"<<endl;cout<<"============================================================ =================="<<endl;for(int i=0;i<N;i++){cout<<a[i]<<" "<<name[i]<<" "<<tel[i]<<"\t"<<water_c.s[i]<<"\t"<<elec_c.s[i]<<"\t"<<comm_c.s[i]<<"\t"<<shop_c.s[i]<<"\t"<<gas_c.s[i]<<"\t"<<pin_c.s[i]<<"\t"<<amount(i)<<endl;}cout<<"============================================================ =================="<<endl;cout<<"所有用户账单总计费用合计:\t"<<all_amount()<<endl;cout<<"============================================================ =================="<<endl;}void user::add() ////类内部添加数据成员函数{cout<<"\t请输入新增用户个数:"<<endl;int n;cin>>n;cout<<"\t请输入这"<<n<<"个用户信息:"<<endl;cout<<"用户名电话号码:"<<endl;for(int i=0;i<n;i++){cin>>name[N]>>tel[N];a[N]=N+1;N++;}if(N==M){cout<<"\t系统设置人数已满,请联系管理员!"<<endl;}}void user::cancel() //类内部删除函数(注销){int m;string s;cout<<"\t注销--->请输入用户编号用户名:"<<endl;cin>>m>>s;int k=0;for(int i=0;i<N;i++){if(m==a[i]&&s==name[i]){for(int j=i;j<N;j++){a[j]=a[j+1];name[j]=name[j+1];tel[j]=tel[j+1];water_c.t[j]=water_c.t[j+1];water_c.s[j]=water_c.s[j+1];elec_c.d[j]=elec_c.d[j+1];elec_c.s[j]=elec_c.s[j+1];comm_c.tp[j]=comm_c.tp[j+1];comm_c.cp[j]=comm_c.cp[j+1];comm_c.s[j]=comm_c.s[j+1];shop_c.sp[j]=shop_c.sp[j+1];shop_c.hp[j]=shop_c.hp[j+1];shop_c.s[j]=shop_c.s[j+1];gas_c.g[j]=gas_c.g[j+1];gas_c.s[j]=gas_c.s[j+1];pin_c.pc[j]=pin_c.pc[j+1];pin_c.pa[j]=pin_c.pa[j+1];pin_c.s[j]=pin_c.s[j+1];}k++;N--;cout<<"用户的信息已删除!"<<endl;break;}}if(k==0){cout<<"用户不存在!"<<endl;}}double user::amount(int m){int i=m;double sum=0.0;sum=water_c.s[i]+elec_c.s[i]+comm_c.s[i]+shop_c.s[i]+gas_c.s[i]+pin_c.s[i];return sum;}double user::all_amount() //所有用户的所有账单总计{double sum=0.0;for(int i=0;i<M;i++){sum=sum+amount(i);}return sum;}//类user外部定义成员函数结束class inter_f //定义一个界面类{public:inter_f(){}; //构造~inter_f(){}; //析构void display(); //声明显示用户信息界面函数///////////////////void check(user* p); //声明用户登记函数void seek(user* p); //声明用户查询函数void show(user* p); //声明显示用户信息函数void add(user* p); //声明用户新增函数void cancel(user* p); //声明用户注销函数void exit(); //声明用户退出函数void limit(user& ru); //声明用户操作界面函数void display2(); //消费明细界面函数///////////////////////void water_cost(user* p); //水费函数void elec_cost(user* p); //电费函数void comm_cost(user* p); //通信费函数void shop_cost(user* p); //购物费函数void gas_cost(user* p); //煤气费函数void pin_cost(user* p); //零用函数void exit2(); //声明退出消费明细函数void limit2(user& ru); //声明消费明细操作界面函数void display1(); //声明显示总信息界面//////////////////////void personal_bill(user* p); //声明个人账单函数void amount_bill(user* p); //账单总计函数void show1(user* p); //声明显示所有用户账务函数void exit1(); //声明财务退出函数void limit1(user& ru); ////总界面函数};void inter_f::display(){cout<<"|===========================|"<<endl;cout<<"|= 用户系统|"<<endl;cout<<"|===========================|"<<endl;cout<<"|= 1.登记! 2.查询! =|"<<endl;cout<<"|===========================|"<<endl;cout<<"|= 3.新增! 4.注销! =|"<<endl;cout<<"|===========================|"<<endl;cout<<"|= 5.显示! 0.退出! =|"<<endl;cout<<"|===========================|"<<endl;cout<<"欢迎进去用户系统!请根据指示操作:"<<endl;}void inter_f::check(user* p) //登记用户函数{cout<<"请输入用户的信息:"<<" (提示:输入0退出用户系统)"<<endl;cout<<"\t您要登记用户个数为:"<<endl;int i;cin>>i;if(i!=0){cout<<"\t请登记这"<<i<<"个用户的信息!"<<endl;cout<<"用户名电话号码:"<<endl;p->set(i);cout<<"用户信息已保存!(可查询查看)"<<endl;}if(error==0){cout<<endl;cout<<"\t退出登记系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::seek(user* p) //查找{p->inquire();if(error==0){cout<<endl;cout<<"\t退出查找系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::show(user* p) //显示{cout<<"\t用户的登记信息为:"<<endl;p->show();if(error==0){cout<<endl;cout<<"\t退出显示系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::add(user* p) //新增{p->add();if(error==0){cout<<"用户的信息已保存!(可查询查看)"<<endl;cout<<endl;cout<<"\t退出新增用户系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::cancel(user* p) //删除{p->cancel();if(error==0){cout<<endl;cout<<"\t退出注销用户系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::exit() //退出函数{cout<<"\t退出用户系统!谢谢使用!"<<endl;display1();}void inter_f::limit(user& ru) //用户系统界面{display();int n;for(;;){cin>>n;switch(n){case 1: check(&ru); break;case 2: seek(&ru); break;case 3: add(&ru); break;case 4: cancel(&ru); break;case 5: show(&ru); break;case 0: exit(); break;default:cout<<"操作错误!请重新输入:"<<endl;}if(n==0) break;}}void inter_f::display2() //消费明细界面{cout<<"|==================================|"<<endl;cout<<"|= 消费明细=|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 1.水费! 2.电费! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 3.通信费! 4.购物费! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 5.煤气费! 6.零用花费! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 0.退出! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"欢迎进入消费明细,请根据指示操作:"<<endl;}void inter_f::water_cost(user* p) //水费函数{p->inquire1();if(cost_n!=-1){p->water_c.set();p->water_c.set_water();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出水费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::elec_cost(user* p) //电费函数{p->inquire1();if(cost_n!=-1){p->elec_c.set();p->elec_c.set_elec();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出电费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::comm_cost(user* p) //通信函数{p->inquire1();if(cost_n!=-1){p->comm_c.set();p->comm_c.set_comm();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出通信费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::shop_cost(user* p) //购物函数{p->inquire1();if(cost_n!=-1){p->shop_c.set();p->shop_c.set_shop();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出购物费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::gas_cost(user* p) //煤气函数{p->inquire1();if(cost_n!=-1){p->gas_c.set();p->gas_c.set_gas();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出煤气费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::pin_cost(user* p){p->inquire1();if(cost_n!=-1){p->pin_c.set();p->pin_c.set_pin();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出煤气费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::exit2(){cout<<"\t退出消费明细!"<<endl;display1();}void inter_f::limit2(user& ru) //消费明细界面{display2();int n;for(;;){cin>>n;switch(n){case 1:water_cost(&ru); break;case 2:elec_cost(&ru); break;case 3:comm_cost(&ru); break;case 4:shop_cost(&ru); break;case 5:gas_cost(&ru); break;case 6:pin_cost(&ru); break;case 0:exit2(); break;default:cout<<"操作错误!请重新输入:"<<endl;}if(n==0) break;}}void inter_f::display1() //财务管理系统界面{cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 财务管理系统=|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 1.用户管理! 2.消费明细! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 3.个人账单查询! 4.账单总计! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 5.显示所有用户账单! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 0.退出管理系统! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"欢迎进入财务管理系统,请根据系统指示操作:"<<endl;}void inter_f::personal_bill(user* p) //个人账单函数{p->inquire1();if(cost_n!=-1){cout<<"====================================================="<<endl;p->water_c.set_water();p->elec_c.set_elec();p->comm_c.set_comm();p->shop_c.set_shop();p->gas_c.set_gas();p->pin_c.set_pin();cout<<"总计消费:"<<p->amount(cost_n)<<"元"<<endl;cout<<"====================================================="<<endl;}cost_n=-1;if(error==0){cout<<endl;cout<<"\t退出个人账单,请根据指示操作:"<<endl;cout<<endl;display1();}}void inter_f::amount_bill(user* p) //账单总计函数{cout<<"========================================"<<endl;cout<<"水费总计:\t"<<p->water_c.get_cost()<<"元\t"<<"用水用户:"<<p->water_c.get_n()<<"个"<<endl;cout<<"电费总计:\t"<<p->elec_c.get_cost()<<"元\t"<<"用电用户:"<<p->elec_c.get_n()<<"个"<<endl;cout<<"通信费总计:\t"<<p->comm_c.get_cost()<<"元\t"<<"通信用户:"<<p->comm_c.get_n()<<"个"<<endl;cout<<"购物费总计:\t"<<p->shop_c.get_cost()<<"元\t"<<"购物用户:"<<p->shop_c.get_n()<<"个"<<endl;cout<<"煤气费总计:\t"<<p->gas_c.get_cost()<<"元\t"<<"煤气用户:"<<p->gas_c.get_n()<<"个"<<endl;cout<<"零用花费总计:\t"<<p->pin_c.get_cost()<<"元\t"<<"零用用户:"<<p->pin_c.get_n()<<"个"<<endl;cout<<"所有用户账单总计费用合计:\t"<<p->all_amount()<<"元"<<endl;cout<<"========================================"<<endl;if(error==0){cout<<endl;cout<<"\t退出账单总计,请根据指示操作:"<<endl;cout<<endl;display1();}}void inter_f::show1(user* p){p->show1();if(error==0){cout<<endl;cout<<"\t退出显示所有用户账单,请根据指示操作:"<<endl;cout<<endl;display1();}}void inter_f::exit1(){cout<<"\t退出财务管理系统!谢谢使用!"<<endl;}void inter_f::limit1(user& ru) //总界面函数{display1();int n;for(;;){cin>>n;switch(n){case 1: limit(ru); break;case 2:limit2(ru); break;case 3:personal_bill(&ru); break;case 4:amount_bill(&ru); break;case 5:show1(&ru); break;case 0:exit1(); break;default:cout<<"操作错误!请重新输入:"<<endl;}if(n==0) break;}}int main(){inter_f U; //定义一个界面类对象user u; //定义一个用户类对象U.limit1(u); //调用界面类对象的函数,包含用户对象}下面是在界面类中定义一个用户类://家庭财务管理系统,本程序扩充至一个小型的集体。

家庭财务管理系统课程设计的原代码

家庭财务管理系统课程设计的原代码

1、frm_borrowgo。

frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Str_text As StringDim strflag As StringPrivate Sub cmd_add_Click()txt_man.Locked = Falsetxt_way。

Locked = Falsetxt_money.Locked = FalseCombo1。

Locked = FalseCheck1。

Enabled = TrueDTPicker1.Enabled = Truetxt_man。

Text = ”"txt_way。

Text = "”txt_money。

Text = "”Combo1。

Text = ”"strflag = "添加”Cmdsave.Enabled = TrueEnd SubPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_del_Click()Dim A As BooleanA = MsgBox(”是否真的要删除这条记录?”,vbOKCancel + 32 + 256, "删除")If A = True ThenExeCutesql ”delete from 借出where 得款人=’" & txt_man。

Text &”’”, Str_textMsgBox ”记录已删除!", ,"删除”If Mydb.RecordCount 〉0 ThenMydb。

MoveNextIf Mydb。

EOF Then Mydb.MoveLastCall DbCall BangdingLabel7。

Caption = Mydb.RecordCountEnd IfEnd IfEnd SubPrivate Sub cmd_edit_Click()On Error Resume NextDim A As Booleantxt_man.Locked = Falsetxt_way.Locked = Falsetxt_money。

C语言财务管理系统(源代码)

C语言财务管理系统(源代码)

#include"stdio.h"#include"stdlib.h"#define MAX_NAME 11#define MAX_DETAIL 21 #define MENU_COUNT 9 #define DATA_FILE "fa.dat" typedef wnum_fi_type{income=1,payout=-1}fi_type;typedef struct_fi_info{int year;int month;fi_type type;char name[MAX_NAME]; float money;char detail[MAX_DETAIL]; }fi_info;typedef struct_fi_data{fi_info info;struct_fi_data *next;}fi_data;void add_income();void search_income();void delete_income();void update_income();void add_payout();void search_payout();void delete_payout();void update_payout();void count_total();void quit();void search_data(fi_type type);void delete_data(fi_type type);void update_data(fi_type type);void initialize();void save_to_file();void clear_data();fi_data *get_last();fi_data *get_previous(fi_data *p);void input_info(fi_info *info);void show_info(fi_data *p[],int count);fi_data *head;char menu[]="===============================================\n" "| 家庭财务管理系统|\n""+---------------------------------------------+\n" "| 收入管理|\n""| 1 添加收入|\n""| 2 查询收入明细|\n""| 3 删除收入|\n""| 4 修改收入|\n""| 支出管理|\n""| 5 添加支出|\n""| 6 查询支出明细|\n""| 7 删除支出|\n""| 8 修改支出|\n""| 统计|\n""| 9 统计总收入总支出|\n""----------------------------------------------+\n" "| 0 退出系统|\n""==============================================+\n"; void(*menu_fun[])()={quit,add_income,search_income,delete_income,update_income,add_payout,search_payout,delete_payout,update_payout,count_total};int main(){int selected=0;initialize();while(selected>=0 && selected<=MENU_COUNT){system("cls");printf(menu);printf(">请选择要进行的操作(%d - %d):",0,MENU_COUNT);if(scanf("%d",&selected)!=1||selected<0||selected>MENU_COUNT){printf(">输入错误!请选择[ %d - %d]之间的数字!按任意键重试...",0,MENU_COUNT); fflush(stdin);getchar();}else{menu_fun[selected]();}selected=0;}}void add_income(){fi_data *p=(fi_data *)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;input_info(&(p->info));if(head==NULL){head=p;}else{get_last(head)->next=p;}}void search_income(){search_data(income);}void delete_income(){delete_data(income);}void update_income(){update_data(income);}void add_payout(){fi_data *p=(fi_data*)malloc(sizeof(fi_data)); memset(p,0,sizeof(fi_data));input_info(&(p->info));if(head==NULL){head=p;}else{get_last(head)->next=p; }}void search_payout() {search_data(payout); }void delete_payout() {delete_data(payout); }void update_payout() {update_data(payout); }void count_total(){float total_income=0.0; float total_payout=0.0; fi_data *p=head;while(p!=NULL){if(p->info.type==income){total_income+=p->info.money;}else{total_payout+=p->info.money;}p=p->next;}printf("+---------+---------+---------+\n");printf("| 合计收入| 合计支出| 结余|\n");printf("+---------+---------+---------+\n");printf("|%12.2f|%12.2f|%12.2f|\n", total_income, total_payout,total_income - total_payout); printf("+---------+---------+---------+\n");printf(">按任意键继续返回主菜单...");fflush(stdin);getchar();}void search_data(fi_type type){int year=0;int month=0;fi_data *p=NULL;fi_data *result[9]={NULL};char input=' ';while(1){printf(">请输入要查询的年月(例如:2009/1)");if(scanf("%d/%d",&year,&month)!=2){printf(">输入错误。

家庭财务管理程序

家庭财务管理程序

#include<stdio.h>void main(){int a,b,c,i,j,k,s,m,sum; /*a代表收入,b代表支出,sum代表家里剩余k代表银行活期,m代表银行定期*/sum=1000;k=2000;s=0;m=0;printf("家庭初始剩余有1000元,银行活期存款2000元,定期存款无。

\n请先选择种类\n收入请输入1,支出请输入2\n存入银行选择3,银行取出选择4,银行活期转为定期选择5,\n选择后输入收入或者支出金额\n");printf(" 收入\t\t支出\t 本次存入银行\t剩余\n");for(i=0;i<=59;i++){scanf("%d",&j);a=0;b=0;c=0;switch(j){case 1: {printf("收入:");scanf("%d",&a);sum=sum+a;printf(" %8d\t %8d\t \t%8d\n",a,b,sum);if(sum>=5000)printf("请存入银行,存期为活期:\n");break;};case 2: {printf("支出");scanf("%d",&b);sum=sum-b;printf(" %8d\t %8d\t \t%8d\n",a,b,sum);if(sum<=100)printf("家里余额不足,请去银行取钱\n");break;};case 3: {printf("存入银行");scanf("%d",&b);sum=sum-b;k=k+b;printf("银行活期存款为%d\n",k);printf(" %8d\t %8d\t %8d\t %8d\n",a,a,b,sum);if(sum<=100)printf("家里余额不足,请去银行取钱\n");else if(k>=10000)printf("请把活期存款存定期一部分:\n");break;}case 4: {printf("取款");scanf("%d",&s);sum=sum+s;k=k-s;printf("银行活期存款为%d\n",k);printf(" %8d\t %8d\t %8d\t %8d\n",a,b,-s,sum) ;if(k>=10000)printf("请把活期存款存定期一部分:\n");if(sum<=100)printf("家里余额不足,请去银行取钱\n");break;}case 5: {printf("活期存款改定期存款");scanf("%d",&c);m=m+c;k=k-c;printf("活期存款为:%d,银行定期存款:%d\n",k,m);break;}}}}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include <stdio.h>#include <stdlib.h>#include <string.h>struct Data{char name[20];char riqi[8];float money;char beizhu[50];};struct list{struct Data info;struct list *next;};struct list *Inhead=NULL;struct list *Intail=NULL;struct list *zhichuhead=NULL;struct list *zhichutail=NULL;struct list *temp=NULL;void chaxun_income();void chaxun_zhichu();void xiugai_income();void xiugai_zhichu();void Save_income(){FILE *fp;fp=fopen("D:\家庭财务管理.txt","w");struct list *p = Inhead;while(p != NULL){fwrite(&p->info, sizeof(struct Data), 1, fp);p = p->next;}fclose(fp);}void Save_zhichu(){FILE *fp;fp=fopen("D:\家庭财务管理支出.txt","w");struct list *p = zhichuhead;while(p != NULL){fwrite(&p->info, sizeof(struct Data), 1, fp);p = p->next;}fclose(fp);}void Open(){FILE *fp;fp=fopen("D:\家庭财务管理.txt","r");if(fp!=NULL){struct Data linshi;while(fread(&linshi, sizeof(struct Data), 1, fp) == 1){temp=(struct list*)malloc(sizeof(struct list));temp->info=linshi;temp->next=NULL;if(Inhead == NULL){Inhead = temp;Intail = temp;}else{Intail->next = temp;Intail = temp;}}fclose(fp);}}void Menu(){ system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1:收入操作\n");printf(" 2:支出操作\n");printf(" 3:统计操作\n");printf(" 0:退出\n");}void Openzhichu(){FILE *fp;fp=fopen("D:\家庭财务管理支出.txt","r");if(fp!=NULL){struct Data linshi;while(fread(&linshi, sizeof(struct Data), 1, fp) == 1){temp=(struct list*)malloc(sizeof(struct list));temp->info=linshi;temp->next=NULL;if(zhichuhead == NULL){zhichuhead = temp;zhichutail = temp;}else{zhichutail->next = temp;zhichutail = temp;}}fclose(fp);}}void mingzi (){char chazhao[20];printf("请输入查询的名字");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void mingzi_zhichu (){char chazhao[20];printf("请输入查询的名字");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void mingzi_xiugai_income(){char xiugai[20];printf("请输入修改的名字");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void mingzi_xiugai_zhichu(){char xiugai[20];printf("请输入修改的名字");fflush(stdin);gets(xiugai);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void riqi(){char chazhao[20];printf("请输入查询的日期");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.riqi,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void riqi_zhichu(){char chazhao[20];printf("请输入查询的日期");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.riqi,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void riqi_xiugai_income(){char xiugai[20];printf("请输入修改的日期");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.riqi,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void riqi_xiugai_zhichu(){char xiugai[20];printf("请输入修改的日期");fflush(stdin);gets(xiugai);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.riqi,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void money (){float chazhao;printf("请输入查询的money");scanf("%f",&chazhao);fflush(stdin);struct list *p = Inhead;while(p != NULL){if(p->info.money==chazhao){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void money_zhichu (){float chazhao;printf("请输入查询的money");scanf("%f",&chazhao);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(p->info.money==chazhao){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void money_xiugai_income(){float xiugai;printf("请输入修改的money");scanf("%f",&xiugai);fflush(stdin);struct list *p = Inhead;while(p != NULL){if(p->info.money==xiugai){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void money_xiugai_zhichu(){float xiugai;printf("请输入修改的money");scanf("%f",&xiugai);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(p->info.money==xiugai){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void beizhu(){char chazhao[20];printf("请输入查询的备注");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.beizhu,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void beizhu_zhichu(){char chazhao[20];printf("请输入查询的备注");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.beizhu,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void beizhu_xiugai_income(){char xiugai[20];printf("请输入修改的备注");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.beizhu,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void beizhu_xiugai_zhichu(){char xiugai[20];printf("请输入修改的备注");fflush(stdin);gets(xiugai);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.beizhu,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void Income_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.添加收入\n");printf(" 2.删除收入\n");printf(" 3.查询收入\n");printf(" 4.显示收入\n");printf(" 5.修改收入\n");printf(" 0.返回上一级\n");}void zhichu_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.添加支出\n");printf(" 2.删除支出\n");printf(" 3.查询支出\n");printf(" 4.显示支出\n");printf(" 5.修改支出\n");printf(" 0.返回上一级\n");}void chaxun_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.按名字查询\n");printf(" 2.按日期查询\n");printf(" 3.按money询\n");printf(" 4.按备注查询\n");printf(" 0.返回上一级\n"); }void xiugai_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.按名字修改\n");printf(" 2.按日期修改\n");printf(" 3.按money修改\n");printf(" 4.按备注修改\n");printf(" 0.返回上一级\n");}void Add_income(){char panduan;do{temp=(struct list*)malloc(sizeof(struct list));printf("姓名");gets(temp->);fflush(stdin);printf("日期(XX年XX月XX日)");gets(temp->info.riqi);fflush(stdin);printf("收入");scanf("%f",&temp->info.money);fflush(stdin);printf("备注");gets(temp->info.beizhu);fflush(stdin);printf("\n");//------自己添加temp->next=NULL;if(Inhead == NULL){Inhead = temp;Intail = temp;}else{Intail->next = temp;Intail = temp;}Save_income();//后面可以添加“继续添加功能”printf("是否(Y/N)继续添加信息\n");panduan=getchar();fflush(stdin);}while(panduan=='Y'||panduan=='y');system("PAUSE");}void Add_zhichu(){char panduan;do{temp=(struct list*)malloc(sizeof(struct list));printf("姓名");gets(temp->);fflush(stdin);printf("日期(XX年XX月XX日)");gets(temp->info.riqi);fflush(stdin);printf("支出");scanf("%f",&temp->info.money);fflush(stdin);printf("备注");gets(temp->info.beizhu);fflush(stdin);printf("\n");//------自己添加temp->next=NULL;if(zhichuhead == NULL){zhichuhead = temp;zhichutail = temp;}else{zhichutail->next = temp;zhichutail = temp;}Save_zhichu();//后面可以添加“继续添加功能”printf("是否(Y/N)继续添加信息\n");panduan=getchar();fflush(stdin);}while(panduan=='Y'||panduan=='y');system("PAUSE");}void Del_income(){char shanchu[20];struct list *p=NULL;struct list *m =NULL;struct list *n =NULL;p=Inhead;printf("请输入删除姓名");gets(shanchu);if(strcmp(Inhead->,shanchu)==0){while(Inhead!=NULL && strcmp(Inhead->,shanchu)==0) {char ch;printf("找到一个数据名字为%s,确认删除Y/N?",shanchu);ch=getchar();fflush(stdin);if(ch=='y'||ch=='Y') Inhead=Inhead->next;else break;}}else{if(strcmp(Intail->,shanchu)==0){do{ m=p;p=p->next;}while(p!=Intail);m->next=NULL;}//删除尾巴else{do{m=p;p=p->next;n=p->next;}while(strcmp(p->,shanchu)!=0&&n->next!=NULL);if(strcmp(p->,shanchu)==0)m->next=n;}}//删除除头节点之外的节点,自己课后完成Save_income();if(Inhead!=NULL){char panduan;printf("是否继续删除(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){Del_income();}}}void Del_zhichu(){char shanchu[20];struct list *p=NULL;struct list *m =NULL;struct list *n =NULL;p=zhichuhead;printf("请输入删除姓名");gets(shanchu);if(strcmp(zhichuhead->,shanchu)==0){while(zhichuhead!=NULL && strcmp(zhichuhead->,shanchu)==0) {char ch;printf("找到一个数据名字为%s,确认删除Y/N?",shanchu);ch=getchar();fflush(stdin);if(ch=='y'||ch=='Y') zhichuhead=zhichuhead->next;else break;}}else{if(strcmp(zhichutail->,shanchu)==0){do{ m=p;p=p->next;}while(p!=zhichutail);m->next=NULL;}//删除尾巴else{do{m=p;p=p->next;n=p->next;}while(strcmp(p->,shanchu)!=0&&n->next!=NULL);if(strcmp(p->,shanchu)==0)m->next=n;}}Save_zhichu();//删除除头节点之外的节点,自己课后完成if(zhichuhead!=NULL){char panduan;printf("是否继续删除(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){Del_zhichu();}}}void xiugai_income(){xiugai_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_xiugai_income();break;case 2: riqi_xiugai_income();break;case 3: money_xiugai_income();break;case 4: beizhu_xiugai_income();break;default: printf("输入错误");break;}}void xiugai_zhichu(){xiugai_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_xiugai_zhichu();break;case 2: riqi_xiugai_zhichu();break;case 3: money_xiugai_zhichu();break;case 4: beizhu_xiugai_zhichu();break;default: printf("输入错误");break;}}void chaxun_income(){chaxun_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi();break;case 2: riqi();break;case 3: money();break;case 4: beizhu();break;default: printf("输入错误");break;}}void chaxun_zhichu(){chaxun_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_zhichu();break;case 2: riqi_zhichu();break;case 3: money_zhichu();break;case 4: beizhu_zhichu();break;default: printf("输入错误");break;}}void Sho_income(){struct list *p = Inhead;while(p != NULL){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);p = p->next;}system("PAUSE");}void Sho_zhichu(){struct list *p = zhichuhead;while(p != NULL){fflush(stdin);printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("支出:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);p = p->next;}system("PAUSE");}void Income(){int choice;while(1){Income_menu();printf("请输入选择");scanf("%d",&choice);fflush(stdin);if(choice==0){break;}elseswitch(choice){case 1: Add_income(); Save_income();break;case 2: Del_income(); Save_income();break;case 3: chaxun_income(); Save_income();break;case 4: Sho_income(); Save_income();break;case 5: xiugai_income(); Save_income();break;}}}void zhichu(){int choice;while(1){zhichu_menu();printf("请输入选择");scanf("%d",&choice);fflush(stdin);if(choice==0){break;}elseswitch(choice){case 1: Add_zhichu(); Save_zhichu();break;case 2: Del_zhichu(); Save_zhichu();break;case 3: chaxun_zhichu(); Save_zhichu();break;case 4: Sho_zhichu(); Save_zhichu();break;case 5: xiugai_zhichu(); Save_zhichu();break;}}}void tongji_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.总收入\n");printf(" 2.总支出\n");printf(" 3.总资金\n");printf(" 0.返回上一级\n");}void zongshouru(){float shouru=0;struct list *linshi;linshi=Inhead;if(linshi!=NULL){do{shouru=linshi->info.money+shouru;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",shouru);system("PAUSE");}}void zongzhichu(){float zhichu=0;struct list *linshi;linshi=zhichuhead;if(linshi!=NULL){do{zhichu=linshi->info.money+zhichu;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",zhichu);system("PAUSE");}}void zongzijin(){float zhichu=0;float zongzijin;struct list *linshi;linshi=zhichuhead;if(linshi!=NULL){do{zhichu=linshi->info.money+zhichu;linshi=linshi->next;}while(linshi!=NULL);}float shouru=0;linshi=Inhead;if(linshi!=NULL){do{shouru=linshi->info.money+shouru;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",shouru-zhichu);system("PAUSE");}}void Tongji(){while(1){tongji_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);if(choice==0){break;}switch(choice){case 1: zongshouru();break;case 2: zongzhichu();break;case 3: zongzijin();break;default: printf("输入错误");break;}}}void Quit(){char panduan;printf("确认退出(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){exit(0);}}int main(){Open();Openzhichu();system("color 72");while(1){Menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: Income();break;case 2: zhichu();break;case 3: Tongji();break;case 0: Quit();break;default: printf("输入错误");break;}}return 0;}。

相关文档
最新文档