商场收银系统(c语言设计)培训资料
- 格式:doc
- 大小:480.00 KB
- 文档页数:19
课程设计课程名称 C语言程序设计课程设计A 题目名称商场收银系统目录1 系统分析 (1)1.1 课程设计内容 (1)1.2 系统功能需求分析 (1)1.3 数据结构设计.................................................................. 错误!未定义书签。
2 系统设计 (2)2.1 总体设计 (2)2.2 详细设计 (2)2.2.1 界面设计 (2)2.2.2 各功能模块的设计 (4)3 系统编码设计 (5)3.1 main函数 (5)4 系统运行 (13)5 总结 (17)1 系统分析1.1 课程设计内容建立一商品信息文件,商品信息包括商品编号、商品名、商品类别、商品数量、商品价格等。
建立一商场收银系统,功能包括:1.系统登录:运行系统时,收银员应输入姓名(或编号)及密码,验证后方可使用系统。
2.收银操作:收银员逐条输入商品编号及数量,系统自动计算金额,输入完毕后显示应付款,当输入实收额后,计算出找赎值。
3.交易完成后按一定格式显示回单(格式参照一般超市中的打印小票)。
4.保存所显示的回单。
5.自动按销售情况更新商品信息文件中的数据。
6.查询收银员销售信息。
7.浏览库存商品信息。
1.2 系统功能需求分析本系统应具有以下功能:1、文件操作功能进行商品信息管理,以文本的形式保存商品最新信息2、数据输入功能个人登录,消费商品基本资料的输入,销售信息输入等3、数据添加、修改、删除功能商品数据更新,个人入库信息修改更新4、计算功能基本计算功能,销售额处理5、查询功能资料库信息查询7、数据显示功能保障客户知情权,对系统输入输出信息的显示2 系统设计2.1 总体设计按系统分析的功能要求将系统划分为以下几个主要功能模块:1、建立新文本库信息模块2、销售系统模块3、商品销售信息回单模块4、商品库更新模块5、销售回单保存模块2.2 详细设计2.2.1 界面设计1、菜单设计主菜单:子菜单:2、输入界面的设计3、信息显示界面的设计2.2.2 各功能模块的设计根据划分的功能模块,定义以下函数实现各功能:(这部分应介绍各函数的原型,各功能模块实现所用的算法,可用流程图描述)1、主函数main()界面显示密码登录系统主菜单界面2、charge函数、receipt_m函数销售界面3、input_s函数4、disp函数3 系统编码设计(这部分将代码列出,注意,每个函数开始处要介绍函数的功能,重要的代码应有注释,代码格式按锯齿式编排)3.1 main函数void main()/*主函数:密码登陆与主页面显示使用*/{int key,j;int x,i;void openf();void newf();loop1:{clrscr();gotoxy(10,4);for(i=0;i<20;i++)printf("# ");gotoxy(10,16);for(i=0;i<20;i++)printf("# ");gotoxy(16,5);printf("this is the salesperson system\n");gotoxy(16,7);printf("1.please iput your number:\n");gotoxy(16,8);scanf("%s",salesperson_num);gotoxy(16,9);printf("2.please input your key;\n");gotoxy(16,10);scanf("%d",&key);for(j=0;j<3;j++){if(strcmp(salesperson_num,salesperson[j].num)==0&&key==salesperson[j].key) break;clrscr();printf("\tyour number or key is wrong\n");printf("\tplease land again\n");getch();goto loop1;}}3.2 clrscr函数/*主页面显示代码,子函数选择界面*/gotoxy(16,8);printf("welcome to use the system\n");gotoxy(16,10);printf("press enter to continue");getch();do{clrscr();gotoxy(10,5);for(i=0;i<20;i++)printf("* ");gotoxy(16,8);printf("1. build the goods warehouse");gotoxy(16,9);printf("2. charge system");gotoxy(16,10);printf("3. receipt message");gotoxy(16,11);printf("4. add to goods message");gotoxy(16,12);printf("5. sell message");gotoxy(16,13);printf("6. display goods stock");gotoxy(16,14);printf("7. exit");gotoxy(10,16);for(i=0;i<20;i++)printf("* ");gotoxy(16,18);printf("please select the menu:");scanf("%d",&x);while(x<1||x>8);switch(x){ case 1:newf(); break;case 2:charge();break;case 3:receipt_m();break;case 4:input_s();break;case 5:sell_m();break;case 6:disp();break;case 7:exit();}}while(1);}3.3 newf函数/*新建库信息函数,建立新文档存储更新商品信息*/ void newf(){ void openf();int i,x;clrscr();do{clrscr();gotoxy(10,5);for(i=0;i<20;i++)printf("* ");gotoxy(16,8);printf("1.the new warehouse filename \n");gotoxy(16,9);printf("2.add the goods message");gotoxy(16,10);printf("3.exit");gotoxy(10,16);for(i=0;i<20;i++)printf("* ");gotoxy(16,18);printf("please select the menu:");scanf("%d",&x);switch(x){ case 1:openf(); break;case 2:input_s();break;case 3:exit();}}while(1);}void openf(){int i;char f;clrscr();/*system("cls");*/printf("\tinput the warehouse filename please\n"); scanf("%s",xname);fp=fopen("xname","a");fp1=fopen("b.txt","w");fprintf(fp1,"%d\t%d",n,n1);fclose(fp1);fp2=fopen("c.txt","w");fp3=fopen("d.txt","w");printf("\tYou were built the warehouse \n");printf("\n\tcontinue to add goods message?(y/n)");f=getch();if(f=='y')input_s();}3.4 charge函数/*销售信息管理系统*/charge(){int i,j,f;int No;float sum=0;float change,receive;clrscr();gotoxy(10,5);for(i=0;i<20;i++)printf("* ");fp1=fopen("b.txt","r");fscanf(fp1,"%d%d",&n,&n1);fclose(fp1);if(( fp=fopen("a.txt","r"))!=NULL)for(i=0;i<n;i++)fscanf(fp,"%d%s%d%d",&goods[i].num,goods[i].name,&goods[i].price,&goods[i].amount); do{printf("\n\tNo.:\t");scanf("%d",&No);printf("\n\tamount:\t");scanf("%d",&j);No--;n1++;goods[No].amount--;sum+=j*goods[No].price;fp2=fopen("c.txt","a");fprintf(fp2,"%s\t%d\t%s\t%d\t%d\n",salesperson_num,goods[No].num,goods[No].name,goods[N o].price,j);fclose(fp2);fp3=fopen("d.txt","a");fprintf(fp3,"%d\n\t%d",goods[No].num,j);fclose(fp3);f=getch();if(f==0)getch();break;}while(1);printf("\n\tsum:\t%5.2f",sum);printf("\n\n\treceive:\t");scanf("%f",&receive);change=receive-sum;printf("\n\tchange:\t%5.2f",change);fp3=fopen("d.txt","a");fprintf(fp3,"\n\t%5.2f\n\t%5.2f\n\t%5.2f",sum,receive,change);fclose(fp3);fp=fopen("a.txt","w");for(i=0;i<n;i++)fprintf(fp,"%d\t%s\t%d\t%d\n",goods[i].num,goods[i].name,goods[i].price,goods[i].amount);fclose(fp);fp1=fopen("b.txt","w");fprintf(fp1,"%d\t%d",n,n1);fclose(fp1);gotoxy(10,20);for(i=0;i<20;i++)printf("* ");gotoxy(16,22);printf("Press any key to exit");getch();}3.5 receipt函数/*客户回单信息*/receipt_m(){int i,No,j;float change,receive,sum;clrscr();gotoxy(10,5);for(i=0;i<20;i++)printf("* ");fp1=fopen("b.txt","r");fscanf(fp1,"%d%d",&n,&n1);fclose(fp1);if(( fp3=fopen("d.txt","r"))!=NULL){ for(i=0;i<n1;i++)fscanf(fp3,"%d\t%d\t%f\t%f\t%f",&goods[No].num,&j,&sum,&receive,&change);for(i=0;i<n1;i++)printf("\n\tNo:\t%d\n\tamount:\t%d\n\tsum:\t%5.2f\n\treceive:%5.2f\n\tchange:\t%5.2f\n",goods[ No].num,j,sum,receive,change);fclose(fp3);}printf("error\n");gotoxy(10,20);for(i=0;i<20;i++)printf("* ");gotoxy(16,22);printf("Press any key to exit");getch();}3.6 input函数/*库存信息更新*/input_s(){int i,f,j=0;clrscr();printf("\tthis is the goods stock,please add the goods message\n");printf("num:name:price:amount:\n");fp1=fopen("b.txt","r");fscanf(fp1,"%d%d",&n,&n1);fp=fopen("a.txt","a");for(i=0;;i++,j++){ scanf("%d%s%d%d",&goods[i].num,goods[i].name,&goods[i].price,&goods[i].amount);n++;fp1=fopen("b.txt","w");fprintf(fp1,"%d\t%d",n,n1);fclose(fp1);printf("\ncontinue?(y/n)");f=getch();if(f=='n'){break;}}for(i=0;i<=j;i++)fprintf(fp,"%d\t%s\t%d\t%d\n",goods[i].num,goods[i].name,goods[i].price,goods[i].amount);fclose(fp);gotoxy(16,20);printf("press any key to break");getch();}3.7 sell函数/*显示最近销售信息*/{ int i,j,No;clrscr();gotoxy(10,5);for(i=0;i<20;i++)printf("* ");printf("\n\tsalesperson_num\tnum\tname\tprice\tsell_num\n");fp1=fopen("b.txt","r");fscanf(fp1,"%d%d",&n,&n1);fclose(fp1);if(( fp2=fopen("c.txt","r"))!=NULL){ for(i=0;i<n1;i++)fscanf(fp2,"%s\t%d\t%s\t%d\t%d\n",salesperson_num,&goods[No].num,goods[No].name,&goods [No].price,&j);for(i=0;i<n1;i++)printf("\t%s\t\t%d\t%s\t%d\t%d\n",salesperson_num,goods[No].num,goods[No].name,goods[No]. price,j);fclose(fp2);}elseprintf("error\n");gotoxy(10,20);for(i=0;i<20;i++)printf("* ");gotoxy(16,22);printf("Press any key to exit");getch();}3.8 display函数/*显示最近销售的库存信息*/disp(){int i;clrscr();gotoxy(10,5);for(i=0;i<20;i++)printf("* ");printf("\n\tinput the warehouse filename\n");gotoxy(10,7);scanf("%s",xname);printf("\tNo.\tname\tprice\tamount\n");fp1=fopen("b.txt","r");fscanf(fp1,"%d",&n);if(( fp=fopen(xname,"r"))!=NULL){ for(i=0;i<n;i++)fscanf(fp,"%d%s%d%d",&goods[i].num,goods[i].name,&goods[i].price,&goods[i].amount);for(i=0;i<n;i++)printf("\t%d\t%s\t%d\t%d\n",goods[i].num,goods[i].name,goods[i].price,goods[i].amount);fclose(fp);}elseprintf("error\n");gotoxy(10,20);for(i=0;i<20;i++)printf("* ");gotoxy(16,22);printf("Press any key to exit");getch();}4 系统运行(这部分介绍程序运行过程,系统操作使用的说明,使用测试数据运行的结果,可将运行结果截图进行说明)密码登陆界面菜单页面销售系统显示界面销售记录商品信息添加销售信息记录信息库信息5 总结本程序在刚开始调试时有很错误,但在我的努力及同学的帮助下都被一一克服,现在在操作本程序时可根据提示进行相关操作,能正确输出结果。