C语言购物卡管理系统_第1页
C语言购物卡管理系统_第2页
C语言购物卡管理系统_第3页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、购物卡管理系统一系统主要功能模块:1实现系统内制卡、发卡功能。2实现系统内购物卡帐户及相关帐户管理。3实现购物卡交易和合法性检查。4实现购物卡交易积分功能。5实现购物卡报表功能。6数据以文件形式存储。提示:制卡:指申请一个购物卡,但还没有使用。发卡:指该卡已经起用。实现卡交易:指从卡中消费掉一定金额。二题目及要求的分析:根据题目要求,系统应该实现以下功能:1制卡:主要是新建出一张购物卡,并输入了顾客部分信息,如、密码等,但卡没有激活,依然不可使用。2发卡:激活新建的购物卡,用户能够使用卡进行各项活动。3消费:进入帐户后,取走少于帐户金额的钱款进行消费,并在帐户少减少相应的金额,增加相应的积分。

2、4存款:进入帐户后,在金额项加上用户要存入的钱款。5报表:显示顾客购物卡上记录的所有信息,除密码外。6存储:购物卡内的信息以文件形式存储。7退出:从系统中退出。8菜单:提供良好的界面,方便用户的操作。代码:#include<stdio.h>#include<ctype.h>/*调用字符函数*/#include<stdlib.h>#include<conio.h>/*通用输入输出库*/#include<string.h>#include<windows.h>intflag=5;structcardcharname20;cha

3、rnumber20;floatmoney;charkey10;floatjifen;floatmid;intpower;structcard*next;save(structcard*head);voidlist();voidjihuo();structcard*chaxun();save(structcard*head)FILE*fp;structcard*q;q=head;if(fp=fopen("e:123.txt”,"ab+")=NULL)(printf("无法打开n");exit(0);while(q!=NULL)(if(fwrite

4、(q,sizeof(structcard),1,fp)!=1)(printf("文件写入错误!");fclose(fp);return(head);q=q->next;fclose(fp);structcard*save1(structcard*head)(FILE*fp;structcard*q;q=head;if(fp=fopen("e:123.txt","wb")=NULL)(printf("无法打开n");exit(0);while(q!=NULL)(if(fwrite(q,sizeof(struct

5、card),1,fp)!=1)(printf("文件写入错误!");fclose(fp);return(head);q=q->next;fclose(fp);structcard*duqu()/读取数据(structcard*head=NULL;structcard*p1,*p2;FILE*fp;if(fp=fopen("e:123.txt”,"rb+")=NULL)(printf("打开文件出错n");exit(0);while(!feof(fp)(if(p1=(structcard*)malloc(sizeof(s

6、tructcard)=NULL)(printf("somethingiswrong!n");fclose(fp);exit(0);if(fread(p1,sizeof(structcard),1,fp)!=1)free(p1);break;if(head=NULL)head=p2=p1;else(p2->next=p1;p2=p1;fclose(fp);return(head);structcard*createlist()(structcard*head,*p,*q;inti;charnum20;head=(structcard*)malloc(sizeof(str

7、uctcard);head->next=NULL;head->money=0;head->jifen=0;system("cls");printf("ntt*注册购物卡*nnn");doprintf("nnt请输入要注册的卡号六位数:");scanf("%s”,head->number);if(strlen(head->number)!=6)system("cls");printf("nnnnnnnnnnttt对不起您的输入有误,请重新输入!nn");Sl

8、eep(1000);system("cls");printf("ntt*注册购物卡*nnn");continue;printf("nnt请输入您的名字:");scanf("%s",head->name);printf("nnt请输入您的密码:");scanf("%s",head->key);head->power=99;while(strlen(head->number)!=6);p=head;system("cls");print

9、f("ntt*注册购物卡*nnn");printf("您的购物卡为:nn");printf("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();voidcost(

10、structcard*q)(structcard*p,*a;p=duqu();a=p;while(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-&g

11、t;jifen)=(p->jifen)+(p->mid);printf("nnttt您的余额为:.2f",p->money);printf("nnnnnttt显示完毕,按任意键返回子菜单.");getche();p=a;save1(p);voidcunkuan(structcard*q)(structcard*p,*a;p=duqu();a=p;while(strcmp(q->number,p->number)!=0)(p=p->next;system("cls");printf("ntt

12、*账户存款*小爪叩);printf("nnnnnn");printf("ttt请输入您的存款金额:");scanf("%f",&p->mid);(p->money)=(p->mid)+(p->money);printf("nnttt您的余额为:.2f",p->money);printf("nnnnnttt显示完毕,按任意键返回子菜单.");getche();p=a;save1(p);voidxiugai(structcard*q)(charkey10,num

13、10;structcard*p,*a;p=duqu();a=p;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(str

14、cmp(key,num)!=0)(system("cls");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修改密码成功!"

15、);Sleep(1000);p=a;save1(p);voidchaxun2(structcard*q)structcard*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

16、->name,p->number,p->money,p->jifen);printf("n");getch();structcard*chaxun()intb,i=0;intflag=9;structcard*head;charnum10,key10;structcard*p,*head1;head1=duqu();p=head1;system("cls");printf("ntt*账户登陆*nnn");printf("nnt请输入您的卡号六位数:");scanf("%s"

17、;,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("%s”,

18、num);p=head1;continue;if(p->power)=99)system("cls");账户登陆printf("ntt*小爪叩);printf("nnnnnnnttt对不起,该卡未激活,请先激活!");getche();system("cls");main();if(p->power=100)(while(flag=9)(printf("nnt请输入密码六位数:");scanf("%s”,key);if(strcmp(key,p->key)=0)(flag=10

19、;if(strcmp(key,p->key)!=0)(system("cls");*账户登陆*nnn");printf("nnnnnnnttt对不起,密码输入错误%d次!",i+1);flag=9;i+;if(i=3)system("cls");printf("nnnnnnnttt密码输入错误三次,系统白动返回主菜单!");Sleep(2000);system("cls");return;if(flag=10)break;while(1)(system("cls&quo

20、t;);printf("*5)printf("账户查询*n");printf("*n");printf("*n");printf("*n");printf("*n");printf("*1*n");printf("*n");printf("*2*n");printf("*n");printf("*n");printf("*n");printf("*n&quo

21、t;);printf("*n");printf("*n");printf("*n");printf("*5)printf("n");printf("tt请选择操作:");3:消费4:修改密码5:返回主菜单scanf("%d",&b);switch(b)(case1:chaxun2(p);break;case2:cunkuan(p);break;case3:cost(p);break;case4:xiugai(p);break;case5:main();def

22、ault:printf("对不起,您的输入有误,请重新输入!");voidjihuo()charx;charnum10;structcard*p,*head1;head1=duqu();p=head1;system("cls");printf("ntt*激活购物卡*nnn");printf("t请输入您要激活的卡号六位数:");scanf("%s",num);while(p!=NULL)if(strcmp(num,p->number)!=0)(p=p->next;elsebreak;

23、while(p=NULL)system("cls");printf("ntt*活购物卡*nnn");printf("nnnnnnttt没有该卡号信息,请重新输入卡号!nn");Sleep(1000);system("cls");printf("ntt*活购物卡*nnn");printf("t请重新输入您申请的卡号(六位数):");scanf("%s”,num);p=head1;system("cls");printf("ntt*nnn&

24、quot;);printf("您的购物卡为:nn");printf("nt姓名积分nn");printf("t%2s%16s%13.2f%13.2f",p->name,p->number,p->money,p->jifen);printf("nnnnnttt确认激活您的购物卡?nnttt<1><2>否");printf("nnttt请选择:");scanf("%c”,&x);switch(x)case'1':sys

25、tem("cls");printf("ntt*nnn");p->power=100;save1(head1);printf("nnnnnnnttt");printf("激活成功,按任意键返回主菜单.");getche();break;case'2':system("cls");购物卡printf("ntt*nnn");printf("nnnnnnnttt");printf("您已放弃激活,按任意键返回主菜单);getche(

26、);break;default:system("cls");购物卡");printf("ntt*nnn");printf("nnnnnnnttt");printf("对不起,您的输入有误,请重新输入!Sleep(2000);voidlist()structcard*p1;p1=duqu();system("cls");printf("ntt*小爪叩);printf("所有购物卡信息为:nnn");printf("nt姓名积分nn");while(

27、p1!=NULL)(printf("t%2s%16s%14.2f%14.2f",p1->name,p1->number,p1->money,p1->jifen);printf("n");p1=p1->next;main()(inta;struct*head;printf("nnnnnnnntttt");printf("欢送使用");printf("nn");printf("t*购物卡管理系统*5,Sleep(1000);system("cls");while(1)(printf("n")

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论