C水费管理系统Word文件下载.docx

上传人:b****5 文档编号:17209484 上传时间:2022-11-28 格式:DOCX 页数:20 大小:165.86KB
下载 相关 举报
C水费管理系统Word文件下载.docx_第1页
第1页 / 共20页
C水费管理系统Word文件下载.docx_第2页
第2页 / 共20页
C水费管理系统Word文件下载.docx_第3页
第3页 / 共20页
C水费管理系统Word文件下载.docx_第4页
第4页 / 共20页
C水费管理系统Word文件下载.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

C水费管理系统Word文件下载.docx

《C水费管理系统Word文件下载.docx》由会员分享,可在线阅读,更多相关《C水费管理系统Word文件下载.docx(20页珍藏版)》请在冰豆网上搜索。

C水费管理系统Word文件下载.docx

该模块主要完成对用户本月收取水费的功能,其流程图如图4所示。

1.进入子菜单2中选择1,进行用户信息的添加;

2.键盘输入要收水费用户的编、名称、收费时间和本月用水量,计算对该用户所收水费;

3.一次用户信息输入完成,系统回到上一级菜单,提示存盘;

4.输入2,进行存盘。

1.3.3存盘模块

该模块主要完成用户收费信息的存盘,详情见流程图5.所示。

1、子菜单2中选择2,进行添加用户信息和所收水费存盘;

2、继续输入用户信息或返回上级菜单。

1.4查询与统计模块

查询、统计模块主要完成对用户基本信息的和收费信息的查询和统计的功能,详情见流程图6所示。

1、从主菜单中选择3,进入查询与统计子菜单3;

2、从子菜单中选择1、2分别进行用户基本信息查询和收费记录的统计;

3、输入要查询用户的名称或编号,系统从consumer文本文档中找到要查询用户的基本信息,屏幕输出信息,返回子菜单3;

4、输入要查询用户收费记录的日期,系统从charge文本文档中找到该用户信息及收费记录,在屏幕上输出,返回子菜单3;

5、如果没找到该用户信息,返回子菜单3。

2程序源代码

#include<

stdio.h>

string.h>

stdlib.h>

fstream.h>

iostream.h>

#defineNULL0

//定义用户基本信息类

由组员郭文君完成

//定义收费信息类

classcharge{

char*name;

//用户名称

char*kind;

//用户类型

floatvolumn;

//本月用水量

floatmoney;

//本月所收水费

char*time;

//收费时间

public:

staticinti;

//交费次数

charge*next;

//指向charge类对象的指针

charge(char*n,char*k,floatv,floatm,char*t)

{

name=newchar[strlen(n)+1];

strcpy(name,n);

kind=newchar[strlen(k)+1];

strcpy(kind,k);

volumn=v;

money=m;

time=newchar[strlen(t)+1];

strcpy(time,t);

++i;

}

charge()

name=newchar[10];

kind=newchar[10];

volumn=0;

money=0;

time=newchar[10];

~charge()//析构函数

--i;

delete[]kind;

delete[]name;

delete[]time;

char*getname()

returnname;

char*getkind()

returnkind;

floatgetvolumn()

returnvolumn;

floatgetmoney()

returnmoney;

char*gettime()

returntime;

voidsetname(char*x)//用成员函数修改私有数据成员

strcpy(name,x);

voidsetkind(char*y)

strcpy(kind,y);

voidsetvolumn(floatz)

volumn=z;

voidsetmoney(floatp)

money=p;

voidsettime(char*q)

strcpy(time,q);

//声明运算符重载函数为charge类的友元函数

friendostream&

operator<

<

(ostream&

os,charge&

ob);

friendistream&

operator>

>

(istream&

is,charge&

};

intcharge:

:

i=0;

//*重载<

运算符函数*

ostream&

operator<

os,charge&

ob)

{

os<

ob.name<

"

"

ob.kind<

ob.volumn<

ob.money<

ob.time<

;

returnos;

}

//*重载>

istream&

operator>

is,charge&

is>

ob.name;

ob.kind;

ob.volumn;

ob.money;

ob.time;

returnis;

consumer*head=NULL;

//用户信息类链表头初始化

charge*link=NULL;

//收费标准类链表头

voidload()//从硬盘读取用户基本信息

voidsave()//将用户信息存入硬盘

voidCload()//从硬盘读取收费信息

ifstreamfin("

charge.txt"

ios:

in|ios:

nocreate);

if(!

fin)

cout<

不能打开文件"

endl<

endl;

exit(0);

else

intcount,x;

fin>

count;

//读入收费类型数

x=1;

while(x<

=count)

{

charge*temp=newcharge;

fin>

*temp;

//读入一个用户收费记录到内存

//将用户记录插入内存链表

if(link==NULL)//链表为空

{

link=temp;

temp->

next=NULL;

}

else//将新节点插入到头结点之前

next=link;

link=temp;

x++;

}

charge:

i=count;

if(link==NULL)charge:

fin.close();

voidCsave()//将用户收费信息存入硬盘

if(link==NULL)Cload();

ofstreamfout("

out);

//存入用户收费记录总条数,以控制读取收费记录时的循环次数

fout<

charge:

i<

charge*p=link;

while(p!

=NULL)

fout<

*p;

p=p->

next;

fout.close();

link=NULL;

cout<

收费信息保存成功!

//**用户基本信息管理***

voidsub2()//子菜单2

intx;

while(x)

voidsub21();

****水量使用管理****"

********************"

*1>

本月所交水费*"

*2>

存盘*"

*0>

返回主菜单*"

*请选择:

cin>

x;

if(x>

=0&

&

x<

=2)

switch(x)

case1:

sub21();

break;

case2:

Csave();

case0:

return;

选择有误,请重新选择!

voidsub21()

charN[20];

charL[20];

charK[20];

floatV;

charD[20];

floatP;

floatsum;

请输入用户编号:

cin>

L;

请输入用户类型:

K;

请输入收费月份:

D;

请输入本月用水量:

V;

if(head==NULL)load();

consumer*ptr=head;

while(ptr!

if(strcmp(ptr->

getnum(),L)!

=0)

ptr=ptr->

else

P=ptr->

getprice();

strcpy(N,ptr->

getname());

break;

charge*temp=newcharge(N,K,V,P,D);

if(link==NULL)Cload();

if(link==NULL)

link=temp;

temp->

else

next=link;

sum=V*P;

用户"

N<

D<

的用水量为:

V<

吨。

本月水费:

sum<

元。

charge:

i++;

水费记录完成,储存请选择存盘!

//*3查询、统计*

//子菜单3

voidsub3()

while

(1)

voidsub31();

//函数原型声明

voidsub32();

******查询、统计******"

**********************"

用户信息查询;

*"

收费记录统计;

返回主菜单;

sub31();

sub32();

elsecout<

voidsub31()//用户信息查询

voidsub311();

voidsub312();

******用户信息查询******"

************************"

根据用户名称查询;

根据用户编号查询;

返回上一菜单;

if(x>

switch(x)

case1:

sub311();

case2:

sub312();

case0:

elsecout<

voidsub311()//根据用户名称查询

consumer*p;

请输入要查找用户的名称:

N;

if(head==NULL)load();

p=head;

if(strcmp(p->

getname(),N)==0)

cout<

*所查找用户的名称:

p->

getname()<

*用户的编号:

getnum()<

*该用户所属类型:

getkind()<

*该用户类型的价格"

getprice()<

return;

该用户不存在!

return;

voidsub312()//按编号查找

charM[20];

consumer*q;

请输入要查找用户的编号:

M;

q=head;

while(q!

if(strcmp(q->

getnum(),M)==0)

q->

q=q->

voidsub32()//收费记录统计

******收费记录统计******"

请输入要查询的时间(时间格式:

2008/08):

gettime(),D)==0)

getvolumn()<

getmoney()*p->

p=p->

elsep=p->

//***主函数****

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1