版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、购物卡管理系统(一)系统主要功能模块: (1)实现系统内制卡、发卡功能。 (2)实现系统内购物卡帐户及相关帐户管理。 (3)实现购物卡交易和合法性检查。 (4)实现购物卡交易积分功能。 (5)实现购物卡报表功能。(6)数据以文件形式存储。 提示: 制卡:指申请一个购物卡,但还没有使用。 发卡:指该卡已经起用。 实现卡交易:指从卡中消费掉一定金额。 (二)题目及要求的分析:根据题目要求,系统应该实现以下功能:(1)制卡:主要是新建出一张购物卡,并输入了顾客部分信息,如姓名、密码等,但卡
2、没有激活,依然不可使用。 (2)发卡:激活新建的购物卡,用户能够使用卡进行各项活动。 (3)消费:进入帐户后,取走少于帐户金额的钱款进行消费,并在帐户少减 少相应的金额,增加相应的积分。 (4)存款:进入帐户后,在金额项加上用户要存入的钱款。 (5)报表:显示顾客购物卡上记录的所有信息,除密码外。 (6)存储:购物卡内的信息以文件形式存储。 (7)退出:从系统中退出。 (8)菜单:提供良好的界面,方便用户的操作。代码:#include <stdio.h>#include<ctype.h> /*调用字符
3、函数*/#include<stdlib.h>#include<conio.h> /*通用输入输出库*/#include<string.h>#include<windows.h>int flag=5;struct cardchar name20;char number20;float money;char key10;float jifen;float mid;int power;struct card *next;save(struct card *head);void list();void jihuo();struct card *chaxu
4、n();save(struct card *head)FILE *fp;struct card *q;q=head;if(fp=fopen("e:123.txt","ab+")=NULL)printf("无法打开n");exit(0);while(q!=NULL)if(fwrite(q,sizeof(struct card),1,fp)!=1)printf("文件写入错误!");fclose(fp);return (head);q=q->next;fclose(fp);struct card *save1(s
5、truct card *head)FILE *fp;struct card *q;q=head;if(fp=fopen("e:123.txt","wb")=NULL)printf("无法打开n");exit(0);while(q!=NULL)if(fwrite(q,sizeof(struct card),1,fp)!=1)printf("文件写入错误!");fclose(fp);return (head);q=q->next;fclose(fp);struct card *duqu()/读取数据 struct
6、 card *head = NULL; struct card *p1, *p2; FILE *fp; if(fp=fopen("e:123.txt","rb+")=NULL) printf("打开文件出错n"); exit(0); while(!feof(fp) if(p1=(struct card*)malloc(sizeof(struct card)=NULL) printf("something is wrong!n"); fclose(fp); exit(0); if(fread(p1,sizeof(st
7、ruct card),1,fp)!=1) free(p1); break; if(head=NULL) head=p2=p1; else p2->next=p1; p2=p1; fclose(fp);return (head);struct card *createlist()struct card *head,*p,*q;int i;char num20;head=(struct card*)malloc(sizeof(struct card);head->next=NULL;head->money=0;head->jifen=0;system("cls&q
8、uot;);printf("ntt*注册购物卡*nnn");doprintf("nnt请输入要注册的卡号(六位数): ");scanf("%s",head->number);if(strlen(head->number)!=6)system("cls");printf("nnnnnnnnnnttt对不起您的输入有误,请重新输入!nn");Sleep(1000);system("cls");printf("ntt*注册购物卡*nnn");cont
9、inue;printf("nnt请输入您的名字: ");scanf("%s",head->name);printf("nnt请输入您的密码: ");scanf("%s",head->key);head->power=99;while(strlen(head->number)!=6);p=head;system("cls");printf("ntt*注册购物卡*nnn");printf("您的购物卡为:nn");printf(&quo
10、t;nt姓 名 卡 号 余 额 积分 nn");printf("t%2s %16s %13.2f %13.2f",p->name,p->number,p->money,p->jifen); getche();p->next=NULL;save(head);printf("nnnnnnttt");printf("购物卡注册成功!nnnntttt按任意键返回.");getche();void cost(struct card *q)struct card *p,*a;p=duqu();a=p;whi
11、le(strcmp(q->number,p->number)!=0)p=p->next;system("cls");printf("ntt*账户消费*nnn");printf("nnnnnn");printf("ttt请输入您的消费金额:");scanf("%f",&p->mid);(p->money)=(p->money)-(p->mid);(p->jifen)=(p->jifen)+(p->mid);printf("
12、;nnttt您的余额为:%.2f",p->money);printf("nnnnnttt显示完毕,按任意键返回子菜单.");getche();p=a;save1(p);void cunkuan(struct card *q)struct card *p,*a;p=duqu();a=p;while(strcmp(q->number,p->number)!=0)p=p->next;system("cls");printf("ntt*账户存款*nnn");printf("nnnnnn")
13、;printf("ttt请输入您的存款金额:");scanf("%f",&p->mid);(p->money)=(p->mid)+(p->money);printf("nnttt您的余额为:%.2f",p->money);printf("nnnnnttt显示完毕,按任意键返回子菜单.");getche();p=a;save1(p);void xiugai(struct card *q)char key10,num10;struct card *p,*a;p=duqu();a=p
14、;while(strcmp(q->number,p->number)!=0)p=p->next;system("cls");printf("ntt*修改账户密码*nnn");printf("nnnn");printf("ttt请输入您的新密码:");scanf("%s",num);printf("nnttt请再次输入您的密码:");scanf("%s",key);if(strcmp(key,num)!=0)system("cls
15、"); printf("ntt*修改账户密码*nnn");printf("nnnnntt对不起,两次输入的密码不一样,修改密码失败!");Sleep(1000);system("cls");if(strcmp(key,num)=0)system("cls"); printf("ntt*修改账户密码*nnn");strcpy(p->key,num);printf("nnnnnnttt修改密码成功!");Sleep(1000);p=a;save1(p);void
16、chaxun2(struct card *q)struct card *p,*a;p=duqu();a=p;while(strcmp(q->number,p->number)!=0)p=p->next;system("cls"); printf("ntt*账户查询*nnn"); printf("t您的账户信息为:nnn"); printf("ntt姓 名 卡 号 余 额 积分 nn"); printf("tt%2s %16s %13.2f %13.2f",p->name,
17、p->number,p->money,p->jifen); printf("n"); getch();struct card *chaxun()int b,i=0;int flag=9;struct card *head;char num10,key10;struct card *p,*head1;head1=duqu();p=head1;system("cls");printf("ntt*账户登陆*nnn");printf("nnt请输入您的卡号(六位数): ");scanf("%s&
18、quot;,num);while(p!=NULL)if(strcmp(num,p->number)!=0)p=p->next;if(p=NULL)system("cls");printf("ntt*账户登陆*nnn");printf("nnnnnnnttt没有该卡号信息,请重新输入!nn");Sleep(1000);system("cls");printf("ntt*账户登陆*nnn"); printf("nnt请重新输入卡号(六位数): ");scanf(&qu
19、ot;%s",num);p=head1;continue;if(p->power)=99)system("cls");printf("ntt*账户登陆*nnn");printf("nnnnnnnttt对不起,该卡未激活,请先激活!");getche();system("cls");main();if(p->power=100)while(flag=9)printf("nnt请输入密码(六位数): ");scanf("%s",key);if(strcmp(
20、key,p->key)=0)flag=10;if(strcmp(key,p->key)!=0)system("cls"); printf("ntt*账户登陆*nnn");printf("nnnnnnnttt对不起,密码输入错误%d次!",i+1);flag=9;i+;if(i=3)system("cls");printf("nnnnnnnttt密码输入错误三次,系统自动返回主菜单!");Sleep(2000);system("cls");return;if(fla
21、g=10)break;while(1)system("cls"); printf(" *n"); printf(" * *n"); printf(" * 账户查询 *n"); printf(" * *n"); printf(" * *n"); printf(" * *n"); printf(" *1:查询 *n"); printf(" * *n"); printf(" *2:存款 *n"); pr
22、intf(" * *n"); printf(" *3:消费 *n"); printf(" * *n"); printf(" *4:修改密码 *n"); printf(" * *n"); printf(" *5:返回主菜单 *n"); printf(" * *n"); printf(" *n"); printf("n"); printf("tt请选择操作: "); scanf("%d&qu
23、ot;,&b); switch(b) case 1:chaxun2(p); break; case 2:cunkuan(p);break; case 3:cost(p);break; case 4:xiugai(p);break; case 5:main(); default:printf("对不起,您的输入有误,请重新输入!"); void jihuo()char x;char num10;struct card *p,*head1;head1=duqu();p=head1;system("cls");printf("ntt*激活购物
24、卡*nnn");printf("t请输入您要激活的卡号(六位数): ");scanf("%s",num);while(p!=NULL)if(strcmp(num,p->number)!=0)p=p->next;elsebreak;while(p=NULL)system("cls");printf("ntt*激活购物卡*nnn");printf("nnnnnnttt没有该卡号信息,请重新输入卡号!nn");Sleep(1000);system("cls")
25、;printf("ntt*激活购物卡*nnn"); printf("t请重新输入您申请的卡号(六位数): ");scanf("%s",num);p=head1;system("cls");printf("ntt*激活购物卡*nnn");printf("您的购物卡为:nn");printf("nt姓 名 卡 号 余 额 积分 nn");printf("t%2s %16s %13.2f %13.2f",p->name,p->nu
26、mber,p->money,p->jifen);printf("nnnnnttt确认激活您的购物卡? nnttt <1> 是 <2> 否");printf("nnttt请选择:");scanf(" %c",&x);switch(x)case '1':system("cls"); printf("ntt*激活购物卡*nnn");p->power=100;save1(head1);printf("nnnnnnnttt&quo
27、t;);printf("激活成功,按任意键返回主菜单.");getche();break;case '2':system("cls"); printf("ntt*激活购物卡*nnn");printf("nnnnnnnttt");printf("您已放弃激活,按任意键返回主菜单.");getche();break;default:system("cls"); printf("ntt*激活购物卡*nnn");printf("nnnnn
28、nnttt");printf("对不起,您的输入有误,请重新输入!");Sleep(2000);void list()struct card *p1; p1=duqu();system("cls");printf("ntt*显示购物卡*nnn");printf("所有购物卡信息为:nnn");printf("nt姓 名 卡 号 余 额 积分 nn");while(p1!=NULL) printf("t %2s %16s %14.2f %14.2f",p1->n
29、ame,p1->number,p1->money,p1->jifen);printf("n");p1=p1->next;main()int a;struct *head;printf("nnnnnnnntttt");printf(" 欢迎使用");printf("nn"); printf("t *购 物 卡 管 理 系 统*n");Sleep(1000);system("cls");while(1)printf("n");printf(" *n");printf(" * 购
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 放假调休协议书
- aptx协议书有几种
- 项目立项协议书
- 2025设备委托研发标准版合同
- 英朗导航 原车协议书
- 家居样板间协议书
- 意向性融资协议书
- 2025租赁合同生效条件
- 《2025年版股权质押贷款合同模板》
- 2025年顺丰快递快递员合同履行违约责任协议
- 语文说课课件
- 食药环案件讲课件
- 口腔粘膜炎品管圈实践应用
- T/CECS 10210-2022给水用胶圈电熔双密封聚乙烯复合管材及管件
- 《心衰课件详解》课件
- 聘请驻厂人员服务合同协议
- 农发行考试试题及答案
- 中国共产主义青年团纪律处分条例试行解读学习
- 2025-2030内衣产业行业市场现状供需分析及投资评估规划分析研究报告
- 中国教育发展战略学会2025-2026年课题:8.新时代立德树人根本任务新生态新格局研究
- 2024年二级注册结构工程师专业考试试题及答案(下午卷)
评论
0/150
提交评论