版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、南京信息工程大学计算机与软件学院 网络工程(2)班实验内容客户消费积分管理系统问题描述:针对客户的消费情况,进行客户管理,根据客户的消费积分对客户实行不同程度的打折优惠。基本要求:1. 采用一定的存储结构进行客户信息的存储;2. 对客户的信息可以进行修改、删除、添加;3. 能够根据消费情况进行客户积分的计算;4. 根据积分情况实行不同程度的打折优惠;实验分析1、概要设计 本系统用到的主要数据结构为数组和文件。 一个数组对应一个客户,里面用3个字符串分别存储着用户的客户号、姓名和消费情况。然后将数组写入文件,查询时读取文件,提取相应信息。2功能模块详细设计 程序总流程4. 详细设计思想本程序运用
2、链表对客户信息进行存储,首先对结点进行定义,结点中的数据域分别定义了消费者的消费号、身份证、消费价格、积分,其中身份证和消费价格用了字符型数组进行定义,然后定义了客户消费信息链表,每添加一个客户,先分配内存,再添加消费者的信息,之后将链表中最后一个指针指向该新的消费者,删除时,需先找到该消费者前面的消费者,直接将其指针指向删除消费者的下一个消费者,修改信息时,先找到该消费者,选择修改的内容,再进行修改,添加消费价格时,先找到该消费者,根据情况对增加或减少消费价格,并根据价格计算积分,打折时,根据消费者打折的要求,进行打折。详细设计和代码4.2 源代码#include#include#inclu
3、de#includetypedef struct Dataytpeint m; char Identity18;char Name20;float Price,Integral;Datatype;/链表结点的定义typedef struct ListnodeDatatype customer; struct Listnode *next;Listnode,*Linklist;int i=1;/消费者编号/创建链表void create(Linklist &h)float money;Linklist s,t;int j=1;char x;h=(Listnode *)malloc(sizeof(
4、Listnode);h-next=NULL;t=h;while(j)s=(Listnode*)malloc(sizeof(Listnode);printf(消费号为%dn,i);s-customer.m=i;printf(请输入身份证号码:);scanf(%c,&x);scanf(%s,s-customer.Identity);printf(n);printf(请输入姓名:);scanf(%c,&x); scanf(%s,s-customer.Name);printf(n);printf(请输入价格:);scanf(%f,&money);printf(n);s-customer.Price=m
5、oney;s-next=NULL;t-next=s;t=s;printf(全部输完,请输入0,否则输入1.n);scanf(%d,&j);printf(n);i+;t-next=NULL;/插入void ListInsert(Linklist&h)int j=1;float money;char x; Linklist s,t; s=(Listnode *)malloc(sizeof(Listnode);printf(消费号为%dn,i+);printf(请输入身份证号码:);scanf(%c,&x);scanf(%s,s-customer.Identity);scanf(%c,&x);pri
6、ntf(n);printf(Please enter the name:);scanf(%s,s-customer.Name);printf(n);printf(Please enter the Price:);scanf(%f,&money);printf(n);s-customer.Price=money; t=h;while(t-next)t=t-next;t-next=s;t=s;s-next=NULL;printf(插入成功!n);/删除void Listdelete(Linklist&h,int m)int j=1; Linklist q=h,t; if(m=1) t=h; h=h
7、-next; else while(jnext!=NULL) q=q-next; j+; if(q-next!=NULL&j=m-1) t=q-next; q-next=t-next; else printf(位置参数不正确!n); i-; free(t);printf(删除成功!n);/修改void change(Linklist&h,int m)int a,j=1;char s18;float n;Linklist t=h;printf(Change customers Identity:1;Name:2;Price:3;Integral:4n);scanf(%d,&a);printf(n
8、);while(jnext!=NULL) t=t-next; j+; printf(OK!n);switch(a)case 1:printf(Please enter the Identity!);scanf(%s,t-customer.Identity);break;case 2:printf(Please enter the Name!);scanf(%s,t-customer.Name);break;case 3:printf(Please enter the Price!n);scanf(%f,&n);t-customer.Price=n;break;case 4:printf(Ple
9、ase enter the Integra!n);scanf(%f,&n);t-customer.Integral=n;break;printf(修改成功!n);/计算价格,计算积分void increase(Linklist &h,int m)int n=1,j;float money;Linklist p=h-next;printf(Money is increased?Yes,please enter1;No,please enter0.);scanf(%d,&j);printf(n);while(nnext!=NULL) p=p-next; n+; printf(Please ente
10、r the money:);scanf(%f,&money);printf(n); if(j) p-customer.Price=p-customer.Price+money;else p-customer.Price=p-customer.Price-money;p-customer.Integral=p-customer.Price;printf(消费号为%dn,m);printf(身份证为%sn,p-customer.Identity);printf(消费者姓名为%sn,p-customer.Name);printf(实际价格为%fn,p-customer.Price);printf(积
11、分为%fn,p-customer.Integral);/计算打折之后的价格(积分在500至1000之间,免费1/100;1000至5000之间,免费3/100;大于5000,免费1/20)void discountsum(Linklist &h,int m)int j=1;Linklist p;p=h; while(jnext!=NULL) p=p-next; j+; p-customer.Integral=p-customer.Price;if(p-customer.Integral=500&p-customer.Integralcustomer.Price=p-customer.Price
12、/100*99;elseif(p-customer.Integral1000&p-customer.Integralcustomer.Price=p-customer.Price/100*97;elsep-customer.Price=p-customer.Price/20*19;printf(消费号为%dn,m);printf(身份证为%sn,p-customer.Identity);printf(消费者姓名为%sn,p-customer.Name);printf(实际价格为%fn,p-customer.Price);printf(积分为%fn,p-customer.Integral);pr
13、intf(打折之后价格:%fn,p-customer.Price);int main()int j=1;Linklist h;while(j)printf(创立消费者消费信息,请选择1n);printf(增添消费者信息,请选择2n);printf(删除消费者信息,请选择3n);printf(修改消费者信息,请选择4n);printf(增添消费价格并计算总消费,请选择5n);printf(根据积分计算打折后消费总价格,请选择6n);printf(退出,请选择0n);scanf(%d,&j);switch(j)case 0:break;case 1:create(h);break;case 2:L
14、istInsert(h);break;case 3:printf(请输入删除的位置:);scanf(%d,&j);Listdelete(h,j);break;case 4:printf(请输入修改的位置:);scanf(%d,&j);change(h,j);break;case 5:printf(请输入消费者的消费号:);scanf(%d,&j);increase(h,j);break;case 6:printf(请输入消费者的消费号:);scanf(%d,&j);discountsum(h,j);break;default:printf(输入错误。n);system(pause); return 0; 程序测试运行程序,进入系
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年年企业增长分析与总结
- 2025年大学二年级(测绘工程)测绘数据处理试题及答案
- 2025年中职(农村电气技术)低压电路维修基础试题及答案
- 2025年大学第二学年(教育学)教育心理学模拟测试试题及答案
- 2025年高职酒店管理(智慧酒店运营)试题及答案
- 2025年中职测绘工程技术(地形测量)试题及答案
- 2025年中职建筑工程造价(工程预算)试题及答案
- 2025年高职(高分子材料工程技术)塑料模具设计综合测试试题及答案
- 2025年高职农产品质量检测(质量检测)试题及答案
- 2025年大学大四(戏剧影视文学)影视导演基础综合测试试题及答案
- 广西出版传媒集团有限公司2026年招聘备考题库附答案详解
- 陶瓷工艺品彩绘师改进水平考核试卷含答案
- 2025广东百万英才汇南粤惠州市市直事业单位招聘急需紧缺人才31人(公共基础知识)测试题附答案
- 2026年日历表含农历(2026年12个月日历-每月一张A4可打印)
- 事业单位考察材料范文
- DB36-T 1158-2019 风化壳离子吸附型稀土矿产地质勘查规范
- 周围神经损伤及炎症康复诊疗规范
- 青海工程建设监理统一用表
- 城市道路照明路灯工程施工组织方案资料
- GA 38-2021银行安全防范要求
- 上海市复旦附中2022年数学高三上期末质量跟踪监视模拟试题含解析
评论
0/150
提交评论