C语言程序课程设计报告商品进销存管理程序.pdf

上传人:白大夫 文档编号:5595226 上传时间:2020-06-21 格式:PDF 页数:46 大小:1.94MB
返回 下载 相关 举报
C语言程序课程设计报告商品进销存管理程序.pdf_第1页
第1页 / 共46页
C语言程序课程设计报告商品进销存管理程序.pdf_第2页
第2页 / 共46页
C语言程序课程设计报告商品进销存管理程序.pdf_第3页
第3页 / 共46页
C语言程序课程设计报告商品进销存管理程序.pdf_第4页
第4页 / 共46页
C语言程序课程设计报告商品进销存管理程序.pdf_第5页
第5页 / 共46页
点击查看更多>>
资源描述

《C语言程序课程设计报告商品进销存管理程序.pdf》由会员分享,可在线阅读,更多相关《C语言程序课程设计报告商品进销存管理程序.pdf(46页珍藏版)》请在三一文库上搜索。

1、. . 一题目及运行说明 商品进销存管理程序 1、题目描述 设计一个商品进销管理程序,该程序具有以下功能: (1) 录入商品信息 ; (2) 给定商品编号,修改该商品信息; (3) 给定商品编号,删除该商品信息; (4) 录入商品的进货和销售信息; (5) 给定商品编号或商品名,查看该商品及库存信息; (6) 统计功能:提供一些统计各类信息的功能。 2、题目要求 (1) 按照分析、设计、编码、调试和测试过程完成应用程序; (2) 学习并使用流程图等工具,并在撰写报告中使用; (3) 程序的各项功能在程序运行时,以菜单形式选择并执行; (4) 要求用户输入数据时,要给出清晰、明确的提示,包括:输

2、入数 据的内容、格式及其结束方式等 (5) 所有的信息存储在一个文件或多个中,并实现文件读写操作。 (6) 程序中用链表存放商品及进销存信息并实现增删减功能。 3、提示 (1) 提醒事件信息可以设计一个结构体类型 . . (2) 自己构思并增加的除规定功能之外的新功能,酌情加分。 (1)程序中主要变量 Struct goods *head 结构体指针 Int n,k struct goods int number; char name20; int shumu; float jiage; struct goods *next; ; int n,k; struct goods *head; 等一

3、些变量。 (2)数据输入的形式和输入值的范围 字符不超过 20 位 整型变量输入大于0 浮点型 变量也大于 0 . . 商品编号为四位整数 (3)数据输入的形式 按程序运行的提示操作 (4)程序所能达到的功能及出错处理 该程序具有以下功能: (1) 录入商品信息 ; (2) 给定商品编号,修改该商品信息; (3) 给定商品编号,删除该商品信息; (4) 录入商品的进货和销售信息; (5) 给定商品编号或商品名,查看该商品及库存信息; (6) 统计功能:提供一些统计各类信息的功能。 二 程序设计思路 根据要求首先设计一个结构体类型,设计好界面,设计好主函数。 程序各功能通过调用子函数来实现 .

4、. 用 switch 来实现菜单的选择 一切数据信息通通存在文件中,并实现文件读写操作。 设计子函数来实现查询,保存,读取数据,删除等操作。 【总体设计 】 图 1 系统功能模块图 【详细设计 】 1. 主函数 主函数设计要求简洁,只提供部分提示语和函数的调用 【程序】 商品管理系统 数据录入数据修改删除商品销售查找进货 . . 图 2. 主函数流程图 具体设计如下: 结构体设计 struct goods int number; char name20; int shumu; float jiage; struct goods *next; ; 主函数设计 显示一系列功能选项 输入 k, 判断

5、 k 是否是 06? 根据 k 的值调用各功能模块函数 结束 开始 k . . void main() void jieman(); void luru(); struct goods *shuju(); void shanchu(struct goods *head); void jinghuo(struct goods *head); void xiaoshu(struct goods *head); void xiugai(struct goods *head); void chaxun(struct goods *head); struct goods *head=NULL; int

6、k=0; system(“cls“); jieman(); printf(“请选择你要的功能键 :“); scanf(“%d“,getchar(); while(k!=0) head=shuju(); switch(k) case 1:luru();break; . . case 2:xiugai(head);break; case 3:chaxun(head);break; case 4:xiaoshu(head);break; case 5:jinghuo(head);break; case 6:shanchu(head);break; case 0:exit(0); default:pr

7、intf(“please try again!n“); jieman(); printf(“请选择你要的功能键 :“); scanf(“%d“, 界面设计 void jieman() printf(“*n“); printf(“欢迎进入商品管理系统n“); printf(“*1 *录入信息 * n“); . . printf(“*2 *修改信息 * n“); printf(“*3 *查询信息 * n“); printf(“*4 *销售信息 * n“); printf(“*5 *进货信息 * n“); printf(“*6 *删除信息 * n“); printf(“*0 *退出系统 * n“);

8、 printf(“欢迎进入商品管理系统n“); printf(“*n“); 文件保存函数设计 struct goods *baocun(struct goods *head) struct goods *shuju(); struct goods *p=NULL; FILE *fp=NULL; char ch=0; getchar(); printf(“是否保存到文件 ?(y/n):“); ch=getchar(); . . putchar(10); if(ch=y|ch=Y) fp=fopen(“goods.txt“,“wb“); p=head; if(fp=NULL) exit(0); w

9、hile(p!=NULL) fprintf(fp,“%dn%sn%dn%ft“,p-number,p-name,p-shumu,p- jiage); p=p-next; printf(“保存成功 !n“); fclose(fp); return(head); . . else if(ch=n|ch=N) printf(“信息未保存到文件 !n“); head=shuju(); return(head); else printf(“sorry,please try again(y/n):“); ch=getchar(); putchar(10); return(head); 数据读取函数设计 s

10、truct goods *shuju() int n=0; FILE *fp; . . struct goods *head=NULL,*p1,*p2; fp=fopen(“goods.txt“,“rb“); if(fp=NULL) printf(“nsorry,读取数据失败 !n“); exit(0); else p1=p2=(struct goods *)malloc(LEN); fscanf(fp,“%d%s%d%f“, while(!feof(fp) n+; if(n=1)head=p1; else p2-next=p1; p2=p1; p1=(struct goods *)mallo

11、c(LEN); fscanf(fp,“%d%s%d%f“, p2-next=NULL; fclose(fp); return(head); 录入函数设计 void luru() struct goods *shuju(); struct goods *baocun(struct goods *head); struct goods *p1,*p2,*p3; head=shuju(); p1=head; p2=(struct goods *)malloc(LEN); printf(“请输入四位编号 :“); scanf(“%d“, . . printf(“请输入商品名 :“); scanf(“%

12、s“,p2-name); printf(“请输入商品数量 :“); scanf(“%d“, printf(“请输入商品价格 :“); scanf(“%f“, if(p1=NULL) p1=p2; p2-next=NULL; baocun(p2); return; while(p1!=NULL) p3=p1;p1=p1-next; p3-next=p2; p2-next=NULL; baocun(head); 进货函数设计 . . void jinghuo(struct goods *head) struct goods *baocun(struct goods *head); int c; i

13、nt p; struct goods *p1,*p2; system(“cls“); printf(“请输入四位编号 :“); scanf(“%d“, p1=head; while(p!=p1-number p1=p1-next; if(p=p1-number) printf(“n 商品编号 t 商品名 t 数量 t 价格 n“); printf(“%dtt%stt%dtt%fn“,p1-number,p1-name,p1-shu mu,p1-jiage); . . printf(“请输入该商品经货个数 :“); scanf(“%d“, p1-shumu=p1-shumu+c; printf(

14、“该商品经货个数 :%dn“,p1-shumu); baocun(head); 删除函数设计 void shanchu(struct goods *head) struct goods *p1,*p2; struct goods *baocun(struct goods *head); int p; system(“cls“); printf(“请输入四位编号 :“); scanf(“%d“, . . p1=head; while(p!=p1-numberp1=p1-next; if(p=p1-number) printf(“n商品编号 t商品名 t 数量 t 价格 n“); printf(“

15、 %dtt%stt%dtt%.2fn“,p1-number,p1-name,p1- shumu,p1-jiage); if(p1=head) head=p1-next; else p2-next=p1-next;n=n-1; printf(“删除成功 !n“); baocun(head); 查询函数设计 void chaxun(struct goods *head) int a,c,i=0; . . struct goods *p1,*p2; char t20; printf(“ 1*商品编号查询 n“); printf(“ 2*商品名字查询 n“); printf(“请选择你需要的功能键 n

16、“); scanf(“%d“, getchar(); if(a=1) printf(“请输入四位编号 :“); scanf(“%d“,getchar(); while(c!=0 while(c!=p1-numberp1=p1-next; if(c=p1-number) printf(“n 商品编号 t 名字 t 数目 t 价格:n“); printf(“ %dt %st %dt %.2fn“,p1-number,p1-nam . . e,p1-shumu,p1-jiage);i=1; else printf(“系 统 中 无 该 商 品 记 录 !press enter return!n“);

17、getchar();system(“cls“);return; if(a=2printf(“请输入商品名字 :“); scanf(“%s“,getchar(); while(strcmp(t,“0“)!=0 if(strcmp(t,p1-name)!=0p1=p1-next; if(strcmp(t,p1-name)=0) printf(“n 商品编号 t 名字 t 数目 t 价格:n“); printf(“ %dt %st %dt %fn“,p1-number,p1-name ,p1-shumu,p1-jiage);i=1; . . else printf(“系 统 中 无 该 商品 记录

18、!press enter return!n“);getchar();system(“cls“);return; 修改函数设计 void xiugai(struct goods *head) struct goods *baocun(struct goods *head); int p,i=0; struct goods *p1,*p2; system(“cls“); printf(“请输入四位编号 :“); scanf(“%d“, getchar(); if(p!=0) p1=head; while(p!=p1-number p1=p1-next; . . if(p=p1-number) pr

19、intf(“n 商品编号 t 名字 t 数目 t 价格:n“); printf(“ %dt %st %dt %fn“,p1-number,p1-name ,p1-shumu,p1-jiage); printf(“请输入要修改的新商品编号 “); scanf(“%d“, i=1; if(i=1) printf(“修改后新商品编号名字 数目 价格:n“); printf(“%d %s %d %f“,p1-number,p1-name ,p1-shumu,p1-jiage); printf(“修改成功 !n“); baocun(head); . . 销售函数设计 void xiaoshu(struc

20、t goods *head) struct goods *baocun(struct goods *head); int c; int p; struct goods *p1,*p2; system(“cls“); printf(“请输入四位编号 :“); scanf(“%d“, getchar(); p1=head; while(p!=p1-number . . p1=p1-next; if(p=p1-number) printf(“n 商品编号 t 商品名 t 数量 t 价格 n“); printf(“%dtt%stt%dtt%fn“,p1-number,p1-name,p1-shu mu

21、,p1-jiage); printf(“请输入该商品售货个数 :“); scanf(“%d“, p1-shumu=p1-shumu-c; printf(“该商品经货个数 :%dn“,p1-shumu); baocun(head); 三 程序清单 . . #include #include #include #include #define LEN sizeof(struct goods) struct goods 结构体 int number; 商品编号 char name20; 商品名 int shumu; 商品数目 float jiage; 商品价格 struct goods *next;

22、 ; int n,k; 全局变量 struct goods *head; 全局变量 void main() 主函数 void jieman(); 界面函数声明 void luru(); 录入函数声明 struct goods *shuju(); 数据读取函数声明 void shanchu(struct goods *head); 删除函数声明 void jinghuo(struct goods *head); 进货函数声明 . . void xiaoshu(struct goods *head); 销售函数声明 void xiugai(struct goods *head); 修改函数声明 v

23、oid chaxun(struct goods *head); 查询函数声明 struct goods *head=NULL; int k=0; system(“cls“); jieman(); printf(“请选择你要的功能键 :“); scanf(“%d“,getchar(); while(k!=0) head=shuju(); switch(k) case 1:luru();break; case 2:xiugai(head);break; case 3:chaxun(head);break; case 4:xiaoshu(head);break; case 5:jinghuo(hea

24、d);break; case 6:shanchu(head);break; case 0:exit(0); default:printf(“please try again!n“); . . jieman(); printf(“请选择你要的功能键 :“); scanf(“%d“, struct goods *baocun(struct goods *head) 保存函数 struct goods *shuju(); struct goods *p=NULL; FILE *fp=NULL; char ch=0; getchar(); printf(“是否保存到文件 ?(y/n):“); 判断是否

25、保存 ch=getchar(); putchar(10); if(ch=y|ch=Y) . . fp=fopen(“goods.txt“,“wb“); p=head; if(fp=NULL) exit(0); while(p!=NULL) fprintf(fp,“%dn%sn%dn%ft“,p-number,p-name,p-shumu,p- jiage); p=p-next; printf(“保存成功 !n“); fclose(fp); return(head); else if(ch=n|ch=N) printf(“信息未保存到文件 !n“); head=shuju(); . . retu

26、rn(head); else printf(“sorry,please try again(y/n):“); ch=getchar(); putchar(10); return(head); void chaxun(struct goods *head) 查询函数 int a,c,i=0; struct goods *p1,*p2; char t20; printf(“ 1*商品编号查询 n“); printf(“ 2*商品名字查询 n“); printf(“请选择你需要的功能键 n“); scanf(“%d“, getchar(); . . if(a=1) printf(“请输入四位编号 :

27、“); scanf(“%d“,getchar(); while(c!=0 while(c!=p1-numberp1=p1-next; if(c=p1-number) printf(“n 商品编号 t 名字 t 数目 t 价格:n“); printf(“ %dt %st %dt %.2fn“,p1-number,p1-nam e,p1-shumu,p1-jiage);i=1; else printf(“系 统 中 无 该 商 品 记 录 !press enter return!n“);getchar();system(“cls“);return; if(a=2printf(“请输入商品名字 :“

28、); scanf(“%s“,getchar(); while(strcmp(t,“0“)!=0 if(strcmp(t,p1-name)!=0p1=p1-next; if(strcmp(t,p1-name)=0) printf(“n 商品编号 t 名字 t 数目 t 价格:n“); printf(“ %dt %st %dt %fn“,p1-number,p1-name ,p1-shumu,p1-jiage);i=1; else printf(“系 统 中 无 该 商品 记录 !press enter return!n“);getchar();system(“cls“);return; . .

29、void jinghuo(struct goods *head) 进货函数 struct goods *baocun(struct goods *head); int c; int p; struct goods *p1,*p2; system(“cls“); printf(“请输入四位编号 :“); scanf(“%d“, p1=head; while(p!=p1-number p1=p1-next; if(p=p1-number) printf(“n 商品编号 t 商品名 t 数量 t 价格 n“); printf(“%dtt%stt%dtt%fn“,p1-number,p1-name,p

30、1-shu mu,p1-jiage); printf(“请输入该商品经货个数 :“); . . scanf(“%d“, p1-shumu=p1-shumu+c; printf(“该商品经货个数 :%dn“,p1-shumu); baocun(head); 保存数据 void luru() struct goods *shuju(); 调用函数 struct goods *baocun(struct goods *head); struct goods *p1,*p2,*p3; head=shuju(); p1=head; p2=(struct goods *)malloc(LEN); prin

31、tf(“请输入四位编号 :“); scanf(“%d“, printf(“请输入商品名 :“); scanf(“%s“,p2-name); . . printf(“请输入商品数量 :“); scanf(“%d“, printf(“请输入商品价格 :“); scanf(“%f“, if(p1=NULL) p1=p2; p2-next=NULL; baocun(p2); return; while(p1!=NULL) p3=p1;p1=p1-next; p3-next=p2; p2-next=NULL; baocun(head); 保存数据 void shanchu(struct goods *h

32、ead) 删除函数 struct goods *p1,*p2; struct goods *baocun(struct goods *head); int p; . . system(“cls“); printf(“请输入四位编号 :“); scanf(“%d“, p1=head; while(p!=p1-numberp1=p1-next; if(p=p1-number) printf(“n商品编号 t商品名 t 数量 t 价格 n“); printf(“ %dtt%stt%dtt%.2fn“,p1-number,p1-name,p1- shumu,p1-jiage); if(p1=head)

33、 head=p1-next; else p2-next=p1-next;n=n-1; printf(“删除成功 !n“); baocun(head); struct goods *shuju() 数据读取函数 . . int n=0; FILE *fp; struct goods *head=NULL,*p1,*p2; fp=fopen(“goods.txt“,“rb“); if(fp=NULL) printf(“nsorry,读取数据失败 !n“); exit(0); else p1=p2=(struct goods *)malloc(LEN); fscanf(fp,“%d%s%d%f“,

34、while(!feof(fp) n+; if(n=1)head=p1; else p2-next=p1; p2=p1; p1=(struct goods *)malloc(LEN); . . fscanf(fp,“%d%s%d%f“, p2-next=NULL; fclose(fp); return(head); void jieman() 界面函数 printf(“*n“); printf(“欢迎进入商品管理系统n“); printf(“*1 *录入信息 * n“); printf(“*2 *修改信息 * n“); printf(“*3 *查询信息 * n“); printf(“*4 *销售

35、信息 * n“); printf(“*5 *进货信息 * n“); printf(“*6 *删除信息 * n“); printf(“*0 *退出系统 * n“); . . printf(“欢迎进入商品管理系统n“); printf(“*n“); void xiaoshu(struct goods *head) 销售函数 struct goods *baocun(struct goods *head); int c; int p; struct goods *p1,*p2; system(“cls“); printf(“请输入四位编号 :“); scanf(“%d“, getchar(); p1

36、=head; while(p!=p1-number p1=p1-next; . . if(p=p1-number) printf(“n 商品编号 t 商品名 t 数量 t 价格 n“); printf(“%dtt%stt%dtt%fn“,p1-number,p1-name,p1-shu mu,p1-jiage); printf(“请输入该商品售货个数 :“); scanf(“%d“, p1-shumu=p1-shumu-c; printf(“该商品经货个数 :%dn“,p1-shumu); baocun(head); 保存数据 void xiugai(struct goods *head) 修

37、改函数 struct goods *baocun(struct goods *head); int p,i=0; struct goods *p1,*p2; system(“cls“); . . printf(“请输入四位编号 :“); scanf(“%d“, getchar(); if(p!=0) p1=head; while(p!=p1-number p1=p1-next; if(p=p1-number) printf(“n 商品编号 t 名字 t 数目 t 价格:n“); printf(“ %dt %st %dt %fn“,p1-number,p1-name ,p1-shumu,p1-j

38、iage); printf(“请输入要修改的新商品编号 “); scanf(“%d“, i=1; . . if(i=1) printf(“修改后新商品编号名字 数目 价格:n“); printf(“%d %s %d %f“,p1-number,p1-name ,p1-shumu,p1-jiage); printf(“修改成功 !n“); baocun(head); 四系统运行 请按要求操作 界面 . . 录入 . . 查询 . . 进货 . . 销售 修改 . . 删除 . . 四小结 通过这次的大型 C语言程序设计, 我从中得到了很多知识运用,让我 加深了对链表的运用及文件的读取操作,结构体的运用。 和同学的讨 论过程中,我又接触到很多不同的思维方法和不同的设计思路,这让 我从中受益多多。 同时,通过这次实验设计, 我学会了一些书本上没有的东西,比如清 屏操作等。对调用函数也有了更深的理解。 对接下来要学习的数据结构有了初步的了解,这次实验设计也为此打 下基础。 . . C语言最重要的就是要多学,多练,这样才能学会熟练运用c 语言。

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

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1