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

上传人:b****7 文档编号:15999186 上传时间:2023-07-09 格式:DOCX 页数:128 大小:442.82KB
下载 相关 举报
C语言程序课程设计商品进销存管理程序docx.docx_第1页
第1页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第2页
第2页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第3页
第3页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第4页
第4页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第5页
第5页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第6页
第6页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第7页
第7页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第8页
第8页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第9页
第9页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第10页
第10页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第11页
第11页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第12页
第12页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第13页
第13页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第14页
第14页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第15页
第15页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第16页
第16页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第17页
第17页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第18页
第18页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第19页
第19页 / 共128页
C语言程序课程设计商品进销存管理程序docx.docx_第20页
第20页 / 共128页
亲,该文档总共128页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

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

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

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

C语言程序课程设计商品进销存管理程序docx

.

 

一题目及运行说明

 

商品进销存管理程序

 

1、题目描述

 

设计一个商品进销管理程序,该程序具有以下功能:

 

(1)录入商品信息;

 

(2)给定商品编号,修改该商品信息;

 

(3)给定商品编号,删除该商品信息;

 

(4)录入商品的进货和销售信息;

 

(5)给定商品编号或商品名,查看该商品及库存信息;

 

(6)统计功能:

提供一些统计各类信息的功能。

 

2、题目要求

 

(1)按照分析、设计、编码、调试和测试过程完成应用程序;

 

(2)学习并使用流程图等工具,并在撰写报告中使用;

 

(3)程序的各项功能在程序运行时,以菜单形式选择并执行;

 

(4)要求用户输入数据时,要给出清晰、明确的提示,包括:

输入数据的内容、格式及其结束方式等

 

(5)所有的信息存储在一个文件或多个中,并实现文件读写操作。

 

(6)程序中用链表存放商品及进销存信息并实现增删减功能。

 

3、提示

 

(1)提醒事件信息可以设计一个结构体类型

 

.

.

 

(2)自己构思并增加的除规定功能之外的新功能,酌情加分。

 

(1)程序中主要变量

 

Structgoods*head结构体指针

 

Intn,k

 

structgoods

 

{intnumber;

 

charname[20];

 

intshumu;

 

floatjiage;

 

structgoods*next;

 

};

 

intn,k;

 

structgoods*head;

 

等一些变量。

 

(2)数据输入的形式和输入值的范围字符不超过20位

 

整型变量输入大于0

 

浮点型变量也大于0

 

.

.

 

商品编号为四位整数

 

(3)数据输入的形式

 

按程序运行的提示操作※

 

(4)程序所能达到的功能及出错处理该程序具有以下功能:

 

(1)录入商品信息;

 

(2)给定商品编号,修改该商品信息;

 

(3)给定商品编号,删除该商品信息;

 

(4)录入商品的进货和销售信息;

 

(5)给定商品编号或商品名,查看该商品及库存信息;

 

(6)统计功能:

提供一些统计各类信息的功能。

 

二程序设计思路

 

根据要求首先设计一个结构体类型,设计好界面,设计好主函数。

 

程序各功能通过调用子函数来实现

 

.

.

 

用switch来实现菜单的选择

 

一切数据信息通通存在文件中,并实现文件读写操作。

设计子函数来实现查询,保存,读取数据,删除等操作。

 

【总体设计】

 

商品管理系统

 

数据录入商品销售数据修改查找删除进货

 

图1系统功能模块图

 

【详细设计】

 

1.主函数

 

主函数设计要求简洁,只提供部分提示语和函数的调用【程序】

 

.

.

 

开始

 

显示一系列功能选项

 

k

输入k,判断k是否是0~6?

 

根据k的值调用各功能模块函数

 

结束

 

图2.主函数流程图

 

具体设计如下:

 

结构体设计

 

structgoods

 

{intnumber;

 

charname[20];

 

intshumu;

 

floatjiage;

 

structgoods*next;

 

};

 

主函数设计

 

.

.

 

voidmain()

 

{

 

voidjieman();

 

voidluru();

 

structgoods*shuju();

 

voidshanchu(structgoods*head);

 

voidjinghuo(structgoods*head);

 

voidxiaoshu(structgoods*head);

 

voidxiugai(structgoods*head);

 

voidchaxun(structgoods*head);

 

structgoods*head=NULL;

 

intk=0;

 

system("cls");

 

jieman();

 

printf("请选择你要的功能键:

");

 

scanf("%d",&k);getchar();

 

while(k!

=0)

 

{

 

head=shuju();

 

switch(k)

 

{case1:

luru();break;

 

.

.

 

case2:

xiugai(head);break;

 

case3:

chaxun(head);break;

 

case4:

xiaoshu(head);break;

 

case5:

jinghuo(head);break;

 

case6:

shanchu(head);break;

 

case0:

exit(0);

 

default:

printf("pleasetryagain!

\n");

 

}

 

jieman();

 

printf("请选择你要的功能键:

");

 

scanf("%d",&k);

 

}

 

}

 

界面设计

 

voidjieman()

 

{

 

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");

 

printf("☆☆☆★★★欢迎进入商品管理系统★★★☆☆☆\n");

 

printf("********************************************\n");

 

}

 

文件保存函数设计

 

structgoods*baocun(structgoods*head)

 

{

 

structgoods*shuju();

 

structgoods*p=NULL;

 

FILE*fp=NULL;

 

charch='\0';

 

getchar();

 

printf("是否保存到文件?

(y/n):

");

 

ch=getchar();

 

.

.

 

putchar(10);

 

if(ch=='y'||ch=='Y')

 

{

 

fp=fopen("goods.txt","wb");

 

p=head;

 

if((fp==NULL)&&(p==NULL))

 

{

 

printf("读取数据失败!

");

 

exit(0);

 

}

 

while(p!

=NULL)

 

{

 

fprintf(fp,"%d\n%s\n%d\n%f\t",p->number,p->name,p->shumu,p->jiage)

 

;

 

p=p->next;

 

}

 

printf("保存成功!

\n");

 

fclose(fp);

 

return(head);

 

.

.

 

}

 

elseif(ch=='n'||ch=='N')

 

{

 

printf("信息未保存到文件!

\n");

 

head=shuju();

 

return(head);

 

}

 

else

 

{

 

printf("sorry,pleasetryagain(y/n):

");

 

ch=getchar();

 

putchar(10);

 

}

 

return(head);

 

}

 

数据读取函数设计

 

structgoods*shuju()

 

{

 

intn=0;

 

FILE*fp;

 

.

.

 

structgoods*head=NULL,*p1,*p2;

 

fp=fopen("goods.txt","rb");

 

if(fp==NULL)

 

{

 

printf("\nsorry,读取数据失败!

\n");

 

exit(0);

 

}

 

else

 

{

 

p1=p2=(structgoods*)malloc(LEN);

 

fscanf(fp,"%d%s%d%f",&p1->number,p1->name,&p1->shumu,&p1->jiage);

while(!

feof(fp))

 

{

 

n++;

 

if(n==1)head=p1;

 

elsep2->next=p1;

 

p2=p1;

 

p1=(structgoods*)malloc(LEN);

 

fscanf(fp,"%d%s%d%f",&p1->number,p1->name,&p1->shumu,&p1->jia

 

.

.

 

ge);

 

}

 

p2->next=NULL;

 

fclose(fp);

 

return(head);

 

}

 

}

 

录入函数设计

 

voidluru()

 

{structgoods*shuju();

 

structgoods*baocun(structgoods*head);

 

structgoods*p1,*p2,*p3;

 

head=shuju();

 

p1=head;

 

p2=(structgoods*)malloc(LEN);

 

printf("请输入四位编号:

");

 

scanf("%d",&p2->number);

 

.

.

 

printf("请输入商品名:

");

 

scanf("%s",p2->name);

 

printf("请输入商品数量:

");

 

scanf("%d",&p2->shumu);

 

printf("请输入商品价格:

");

 

scanf("%f",&p2->jiage);

 

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);

 

}

 

进货函数设计

 

.

.

 

voidjinghuo(structgoods*head)

 

{structgoods*baocun(structgoods*head);

 

intc;

 

intp;

 

structgoods*p1,*p2;

 

system("cls");

 

printf("请输入四位编号:

");

 

scanf("%d",&p);

 

p1=head;

 

while(p!

=p1->number&&p1->next!

=NULL)

 

{

 

p2=p1;

 

p1=p1->next;

 

}

 

if(p==p1->number)

 

{

 

printf("\n商品编号\t商品名\t数量\t价格\n");

 

printf("%d\t\t%s\t\t%d\t\t%f\n",p1->number,p1->name,p1->shumu,p1->jiage);

.

.

 

printf("请输入该商品经货个数:

");

 

scanf("%d",&c);

 

p1->shumu=p1->shumu+c;

 

printf("该商品经货个数:

%d\n",p1->shumu);

 

}

 

baocun(head);

 

}

 

删除函数设计

 

voidshanchu(structgoods*head)

 

{structgoods*p1,*p2;

 

structgoods*baocun(structgoods*head);

 

intp;

 

system("cls");

 

printf("请输入四位编号:

");

 

scanf("%d",&p);

 

.

.

 

p1=head;

 

while(p!

=p1->number&&p1->next!

=NULL)

 

{p2=p1;p1=p1->next;}

 

if(p==p1->number)

 

{printf("\n商品编号\t商品名\t数量\t价格\n");

 

printf("%d\t\t%s\t\t%d\t\t%.2f\n",p1->number,p1->name,p1->shumu,p

 

1->jiage);

 

if(p1==head)head=p1->next;

 

elsep2->next=p1->next;n=n-1;

 

}

 

printf("删除成功!

\n");

 

baocun(head);

 

}

 

查询函数设计

 

voidchaxun(structgoods*head)

 

{

 

inta,c,i=0;

 

structgoods*p1,*p2;

 

.

.

 

chart[20];

 

printf("1*商品编号查询\n");

 

printf("2*商品名字查询\n");

 

printf("请选择你需要的功能键\n");

 

scanf("%d",&a);

 

getchar();

 

if(a==1)

 

{

 

printf("请输入四位编号:

");

 

scanf("%d",&c);getchar();

 

while(c!

=0&&i==0)

 

{

 

p1=head;

 

while(c!

=p1->number&&p1->next!

=NULL)

 

{p2=p1;p1=p1->next;}

 

if(c==p1->number)

 

{printf("\n商品编号\t名字\t数目\t价格:

\n");

 

printf("%d\t%s\t%d\t%.2f\n",p1->number,p1->name,p1->s

 

humu,p1->jiage);i=1;}

 

.

.

 

else{printf("系统中无该商品记录!

pressenter

 

return!

\n");getchar();system("cls");return;}

 

}

 

}

 

if(a==2&&i==0)

 

{

 

system("cls");printf("请输入商品名字:

");

 

scanf("%s",&t);getchar();

 

while(strcmp(t,"0")!

=0&&i==0)

 

{

 

p1=head;

 

if(strcmp(t,p1->name)!

=0&&p1->next!

=NULL)

 

{

 

p2=p1;p1=p1->next;

 

}

 

if(strcmp(t,p1->name)==0)

 

{

 

printf("\n商品编号\t名字\t数目\t价格:

\n");

 

printf("%d\t%s\t%d\t%f\n",p1->number,p1->name,p1->s

 

humu,p1->jiage);i=1;}

 

else{printf("系统中无该商品记录!

pressenter

 

.

.

 

return!

\n");getchar();system("cls");return;}

 

}

 

}

 

}

 

修改函数设计

 

voidxiugai(structgoods*head)

 

{structgoods*baocun(structgoods*head);

 

intp,i=0;

 

structgoods*p1,*p2;

 

system("cls");

 

printf("请输入四位编号:

");

 

scanf("%d",&p);

 

getchar();

 

if(p!

=0)

 

{

 

p1=head;

 

while(p!

=p1->number&&p1->next!

=NULL)

 

{

 

p2=p1;

 

p1=p1->next;

 

}

 

if(p==p1->number)

 

.

.

 

{printf("\n商品编号\t名字\t数目\t价格:

\n");

 

printf("%d\t%s\t%d\t%f\n",p1->number,p1->name,p1->s

 

humu,p1->jiage);

 

printf("请输入要修改的新商品编号");

 

scanf("%d",&p1->number);

 

i=1;

 

}

 

if(i==1)

 

{

 

printf("修改后新商品编号名字数目价格:

\n");

 

printf("%d%s%d%f",p1->number,p1->name,p

 

1->shumu,p1->jiage);

 

printf("修改成功!

\n");

 

baocun(head);

 

}

 

}

 

}

 

.

.

 

销售函数设计

 

voidxiaoshu(structgoods*head)

 

{structgoods*baocun(structgoods*head);

 

intc;

 

intp;

 

structgoods*p1,*p2;

 

system("cls");

 

printf("请输入四位编号:

");

 

scanf("%d",&p);

 

getchar();

 

p1=head;

 

while(p!

=p1->number&&p1->next!

=NULL)

 

{

 

p2=p1;

 

p1=p1->next;

 

.

.

 

}

 

if(p==p1->number)

 

{

 

printf("\n商品编号\t商品名\t数量\t价格\n");

 

printf("%d\t\t%s\t\t%d\t\t%f\n",p1->number,p1->name,p1->shumu,p1->jiage);

printf("请输入该商品售货个数:

");

 

scanf("%d",&c);

 

p1->shumu=p1->shumu-c;

 

printf("该商品经货个数:

%d\n",p1->shumu);

 

}

 

baocun(head);

 

}

 

三程序清单

 

#include

 

.

.

 

#include

 

#include

 

#include

 

#defineLENsizeof(structgoods)

 

structgoods结构体

 

{intnumber;

商品编号

charname[20];

商品名

intshumu;

商品数目

floatjiage;商品价格

structgoods*next;

 

};

 

intn,k;全局变量

 

structgoods*head;全局变量

 

voidmain()主函数

 

{

 

voidjieman();界面函数声明

 

voidluru();录入函数声明

 

structgoods*shuju();数据读取函数声明

 

voidshanchu(structgoods*head);删除函数声明

 

voidjinghuo(structgoods*head);进货函数声明

 

voidxiaoshu(structgoods*head);销售函数声明

 

.

.

 

voidxiugai(structgoods*head);修改函数声明

 

voidchaxun(structgoods*head);查询函数声明

 

structgoods*head=NULL;

 

intk=0;

 

system("cls");

 

jieman();

 

printf("请选择你要的功能键:

");

 

scanf("%d",&k);getchar();

 

while(k!

=0)

 

{

 

head=shuju();

 

switch(k)

 

{case1:

luru();break;

 

case2:

xiugai(head);break;

 

case3:

chaxun(head);break;

 

case4:

xiaoshu(head);break;

 

case5:

jinghuo(head);break;

 

case6:

shanchu(head);break;

 

case0:

exit(0);

 

default:

printf("please

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

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2