C语言超市收银系统.docx
《C语言超市收银系统.docx》由会员分享,可在线阅读,更多相关《C语言超市收银系统.docx(19页珍藏版)》请在冰豆网上搜索。
C语言超市收银系统
C语言-超市收银系统
printf("\t\t|欢迎使用结账管理系统|\n");
printf("\t\t|-----------------------------------------|\n");
printf("\t\t||\n");
printf("\t\t|1.商品管理|\n");
printf("\t\t||\n");
printf("\t\t|2.结账模式|\n");
printf("\t\t||\n");
printf("\t\t|3.退出系统|\n");
printf("\t\t||\n");
printf("\t\t|_________________________________________|\n");
printf("\n\t\t请输入您要进行的操作(1--3)[]\b\b");
scanf("%d",&n);
while(n!
=1&&n!
=2&&n!
=3)
{
printf("提示:
\n\t输入有误,请重新输入您要进行的操作(1--3):
\n");
scanf("%d",&n);
}
returnn;
}
intmenu2(void)//商品管理页面
{
intn;
system("cls");
printf("\n\n\n");
printf("\t\t-----------------------------------------\n");
printf("\t\t|商品信息管理页面|\n");
printf("\t\t|-----------------------------------------|\n");
printf("\t\t||\n");
printf("\t\t|1.新购商品入库|\n");
printf("\t\t|2.商品信息删除|\n");
printf("\t\t|3.商品信息修改|\n");
printf("\t\t|4.商品信息查询|\n");
printf("\t\t|5.商品信息浏览|\n");
printf("\t\t|6.返回主菜单|\n");
printf("\t\t||\n");
printf("\t\t|_________________________________________|\n");
printf("\n\t请输入您要进行的操作(1--6)[]\b\b");
scanf("%d",&n);
while(n!
=1&&n!
=2&&n!
=3&&n!
=4&&n!
=5&&n!
=6)
{
printf("提示:
\n输入有误,请重新输入您要进行的操作(1--6):
\n");
scanf("%d",&n);
}
returnn;
}
intmenu9(void)//结账页面
{
system("cls");
floattot=0,pay=0;
if(len!
=0)
{
inti;
system("cls");
printf("\n\n\n");
printf("\t\t-----------------------------------------\n");
printf("\t\t|商品结账页面|\n");
printf("\t\t|-----------------------------------------|\n");
printf("\t\t编号\t名称\t产地\t数量\t单价\n");
printf("-------------------------------------------------------------------\n");
for(i=0;i{
printf("\t\t%d\t%s\t%s\t%d\t%d\t\n\n",thing[i].id,thing[i].name,
thing[i].produce,thing[i].number,thing[i].money);
tot=(float)((thing[i].number*thing[i].money*10)/10);
pay+=tot;
}
printf("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t总共消费:
%.2f\n\n",pay);
system("pause");
}
else
{
printf("\t亲~购物车中没有商品,请先添加商品信息哟~~");
system("pause");
}
return0;
}
intmenu8(void)//商品信息删除
{
inti,j,num,e,t=len;
if(len!
=0)
{
printf("\t请输入您要删除的商品的编号:
");
scanf("%d",&num);
for(i=0;iif(thing[i].id==num)
j=i;
if(j!
=(t-1))
{
for(e=i-1;e{
thing[j].id=thing[j+1].id;
strcpy(thing[j].name,thing[j+1].name);
strcpy(thing[j].produce,thing[j+1].produce);
thing[j].number=thing[j+1].number;
thing[j].money=thing[j+1].money;
t--;
p++;
}
}else{t--;p--;}
printf("提示:
删除完毕!
");
system("pause");
}
else
{
printf("暂无数据,请先添加商品信息!
");
system("pause");
}
return0;
}
intmenu7(void)//商品信息查询
{
intj,i,c,w;
charname[20];
if(len!
=0)
{
do
{
system("cls");
printf("\n\n\n");
printf("\t\t---------------------------------\n");
printf("\t\t|商品信息查询|\n");
printf("\t\t|---------------------------------|\n");
printf("\t\t||\n");
printf("\t\t|按编号查询请按1|\n");
printf("\t\t|按名称查询请按2|\n");
printf("\t\t|取消请按0|\n");
printf("\t\t|_________________________________|\n");
printf("\t请输入您的选择:
");
scanf("%d",&c);
switch(c)
{
case0:
break;
case1:
printf("\t请输入商品的编号;");
scanf("%d",&w);
for(i=0;iif(thing[i].id==w)
{
system("cls");
printf("\n\n\t\t------------\n");
printf("\t\t商品编号:
%d\n",thing[i].id);
printf("\t\t商品名称:
%s\n",thing[i].name);
printf("\t\t商品产地:
%s\n",thing[i].produce);
printf("\t\t商品数量:
%d\n",thing[i].number);
printf("\t\t商品价格:
%d\n",thing[i].money);
system("pause");
j=1;
}
if(j==0)
printf("提示:
\n\t没有该商品记录,请核对!
");
break;
case2:
printf("\t请输入商品的姓名:
");
scanf("%s",name);
for(i=0;iif(strcmp(name,thing[i].name)==0)
{
system("cls");
printf("\n\n\t\t------------\n");
printf("\t\t商品编号:
%d\n",thing[i].id);
printf("\t\t商品名称:
%s\n",thing[i].name);
printf("\t\t商品产地:
%s\n",thing[i].produce);
printf("\t\t商品数量:
%d\n",thing[i].number);
printf("\t\t商品价格:
%d\n",thing[i].money);
j=1;
system("pause");
}
if(j==0)
printf("提示:
没有该商品记录,请核对!
");
break;
default:
printf("\n提示:
您的输入有误,请重新输入!
");
break;
}//属于switch
}while(c!
=0);//属于do
}//属于if
else
{
printf("暂无数据,请先添加商品信息!
");
system("pause");
}
return0;
}
intmenu6(void)//商品信息修改
{
intnum;
inti,c;
if(len!
=0)
{
system("cls");
printf("\t请输入您要修改的商品的编号:
");
scanf("%d",&num);
for(i=0;i{if(thing[i].id==num)
break;
}
do
{
system("cls");
printf("\n\n\n");
printf("请选择您要修改的商品的信息内容:
\n");
printf("\t\t---------------------------------\n");
printf("\t\t|商品管理系统|\n");
printf("\t\t|---------------------------------|\n");
printf("\t\t||\n");
printf("\t\t|名称请按1|\n");
printf("\t\t|数量请按2|\n");
printf("\t\t|产地请按3|\n");
printf("\t\t|价格请按4|\n");
printf("\t\t|取消请按0|\n");
printf("\t\t|_________________________________|\n");
printf("\t请输入您的选择:
");
scanf("%d",&c);
switch(c)
{
case0:
break;
case1:
printf("请输入新的商品名称:
");
scanf("%s",thing[i].name);
break;
case2:
printf("请输入新的商品数量:
");
scanf("%d",&thing[i].number);
break;
case3:
printf("请输入新的商品产地:
");
scanf("%s",thing[i].produce);
break;
case4:
printf("请输入新的商品价格:
");
scanf("%d",&thing[i].money);
break;
default:
printf("\n提示:
您的输入有误,请重新输入!
");
break;
}
if(c==1||c==2||c==3||c==4)
{
printf("\n\t修改成功");
system("pause");
}
}while(c!
=0);
printf("\n\t正在保存数据中.");
for(i=0;i<10;i++)
{
printf(".");
Sleep(500);
}
}
else
{
printf("暂无数据,请先添加商品信息!
");
system("pause");
}
return0;
}
intmenu4(void)//添加商品信息页面
{
inti=0,t;
system("cls");
printf("\n\n\n");
printf("\t\t-----------------------------------------\n");
printf("\t\t|添加商品信息页面|\n");
printf("\t\t|-----------------------------------------|\n");
if(len==0)
p=thing;
printf("\t请输出你要添加的商品个数:
");
scanf("%d",&len);
t=len;
do
{
printf("\t\t商品编号:
%d\n",++i);
p->id=i;
printf("\t\t商品名称:
");
scanf("%s",p->name);
printf("\t\t商品产地:
");
scanf("%s",p->produce);
printf("\t\t商品数量:
");
scanf("%d",&p->number);
printf("\t\t商品价格:
");
scanf("%d",&p->money);
t--;
p++;
printf("\t\t------------\n");
}while(t!
=0);
printf("\n\t已经添加成功,即将返回上一级页面.");
for(i=0;i<10;i++)
{
printf(".");
Sleep(500);
}
return0;
}
intmenu5(void)//查看已经添加的商品
{
if(len!
=0)
{
inti;
system("cls");
printf("\n\n\n");
printf("\t\t-----------------------------------------\n");
printf("\t\t|查看商品信息页面|\n");
printf("\t\t|-----------------------------------------|\n");
if(len!
=0)
{
for(i=0;i{
printf("\t\t商品编号:
%d\n",thing[i].id);
printf("\t\t商品名称:
%s\n",thing[i].name);
printf("\t\t商品产地:
%s\n",thing[i].produce);
printf("\t\t商品数量:
%d\n",thing[i].number);
printf("\t\t商品价格:
%d\n",thing[i].money);
printf("\t\t------------\n");
}
}
else
printf("暂无数据,请先添加商品信息!
");
printf("\n\n");
system("pause");
}
else
{
printf("暂无数据,请先添加商品信息!
");
system("pause");
}
return0;
}
intmenu3(void)//退出页面
{
system("cls");
printf("\n\n\n");
printf("\t\t-----------------------------------------\n");
printf("\t\t|结账管理系统|\n");
printf("\t\t|-----------------------------------------|\n");
printf("\t\t||\n");
printf("\t\t||\n");
printf("\t\t||\n");
printf("\t\t|感谢使用本程序!
!
!
|\n");
printf("\t\t||\n");
printf("\t\t||\n");
printf("\t\t||\n");
printf("\t\t|_________________________________________|\n");
return0;
}
intsign(void)//欢迎页面
{
inti;
printf("\n\n\n");
printf("\t\t-----------------------------------------\n");
printf("\t\t|欢迎使用本程序|\n");
printf("\t\t|-----------------------------------------|\n");
printf("\t\t||\n");
printf("\t\t|小型超市管理系统|\n");
printf("\t\t||\n");
printf("\t\t|by:
吴俊龙|\n");
printf("\t\t||\n");
printf("\t\t|成都工业学院|\n");
printf("\t\t|1405173班|\n");
printf("\t\t|_________________________________________|\n");
printf("\n\n\t\t\t程序正在启动中>");
for(i=0;i<10;i++)
{
printf(">");
Sleep(500);
}
return0;
}
intmain(void)//主函数
{
sign();//版权
system("colorf0");
system("cls");
back:
switch(menu1())
{
case1:
//主函数商品管理页面
{
come:
switch(menu2())
{
case1:
//添加商品信息(完成)
menu4();
gotocome;
break;
case2:
//商品信息删除(完成)
menu8();
gotocome;
break;
case3:
//商品信息修改(完成)
menu6();
gotocome;
break;
case4:
//商品信息查询(完成)
menu7();
gotocome;
break;
case5:
//商品信息浏览(完成)
menu5();
gotocome;
break;
case6:
//返回主菜单(完成)
gotoback;
break;
}
break;
}
case2:
//主页面结账模式
menu9();
gotoback;
break;
case3:
//主页面退出
menu3();
break;
}
Sleep(3000);
return0;
}