汽车租赁管理系统c语言课程设计.docx
《汽车租赁管理系统c语言课程设计.docx》由会员分享,可在线阅读,更多相关《汽车租赁管理系统c语言课程设计.docx(13页珍藏版)》请在冰豆网上搜索。
汽车租赁管理系统c语言课程设计
#include
#include
#include
#include
structmember
{
intcardnum;
charlendcar[10];
}member[5];
structcar
{
intcarnum;
charcarname[20];
floatcarprice;
charcarcreat[20];
intturefalse;
}car[5];
structcard
{
intcardnum;
charsex[5];
charmembersname[20];
longintmemberstel;
}card[5];
findcar()
{
charcarname[10];
inti;
printf("\n\n请输入你要查找的车型:
\n");
scanf("%s",carname);
for(i=0;i<5;i++)
{
while(strcmp(carname,car[i].carname)==0)
{
if(car[i].turefalse==1)
{
printf("编号车型品牌\n%d%s%s\n",car[i].carnum,car[i].carname,car[i].carcreat);
printf("\n\n");
printf("---------------此车现在无人租用\n.");
printf("---------------按任意键返回\n");break;
}
else{printf("\n\n---------------这辆车已经有人借出\n");break;}
}
}
return0;
}
findcar1()
{
charcarcreat[10];
inti;
printf("\n\n请输入你要查找的品牌:
\n");
scanf("%s",carcreat);
for(i=0;i<5;i++)
{
while(strcmp(carcreat,car[i].carcreat)==0)
{
if(car[i].turefalse==1)
{
printf("编号车型品牌\n%d%s%s\n",car[i].carnum,car[i].carname,car[i].carcreat);
printf("\n\n");
printf("---------------此车现在无人租用\n.");
printf("---------------按任意键返回\n\n");break;
}
else{printf("\n\n---------------这辆车已经有人借出!
\n");printf("---------------按任意键返回\n\n");break;}
}
}
return0;
}
chacar()
{
charch5;
do
{
printf("\n\n1:
按车型查找\n");
printf("2:
按品牌查找\n");
printf("0:
返回\n");
printf("请输入0━2:
\n");
ch5=getch();
switch(ch5)
{
case'1':
findcar();getch();break;
case'2':
findcar1();getch();break;
case'0':
break;
default:
printf("---------------无此操作!
\n");getch();break;
}
}while(ch5!
='0');
return0;
}
lendcar()
{
inti,n;
intcardnum;
printf("\n\n请输入卡号:
\n");
scanf("%d",&cardnum);
for(i=0;i<5;i++)
{
if(card[i].cardnum==cardnum)
{
n=i;
printf("\n车型:
");
scanf("%s",member[n].lendcar);
for(i=0;i<5;i++)
{if(strcmp(car[i].carname,member[n].lendcar)==0)
{
if(car[i].turefalse==0)
{printf("---------------对不起,此车已被租出,请重新选择\n");
getch();return0;
}
else
member[n].cardnum=cardnum;
for(i=0;i<5;i++)
{
if(strcmp(car[i].carname,member[n].lendcar)==0)
{
car[i].turefalse=0;
continue;
}
}
printf("\n\n---------------操作成功,请及时提车.");
printf("\n---------------按任意键返回...\n");
getch();
return0;
}
}
printf("\n\n---------------错误操作.");
printf("\n---------------按任意键返回...\n");
getch();
return0;
}
}
printf("\n\n---------------你的卡号不存在,请申请新卡.\n");
printf("\n---------------按任意键返回...\n");
getch();
return0;}
huancar()
{
inti,n;
intcardnum;
charlendcar[10];
printf("\n\n\n");
printf("---欢迎进入还车界面---");
printf("\n\n请你输入你的卡号:
");
scanf("%d",&cardnum);
for(i=0;i<5;i++)
{
if(card[i].cardnum==cardnum)
{
n=i;
printf("\n请输入你要归还的车型:
");
scanf("%s",lendcar);
for(i=0;i<5;i++)
{
while(strcmp(member[i].lendcar,lendcar)==0)
{car[i].turefalse=1;
break;
}
printf("\n\n---------------还车完毕.");
printf("\n---------------按任意键返回...\n");
getch();
return1;
}
printf("\n\n---------------租赁记录不存在.");
printf("\n---------------按任意键返回...\n");
getch();
return0;
}
else{
printf("\n\n---------------卡号不存在,请与管理员联系.\n");
printf("\n---------------按任意键返回...\n");
getch();
return0;}}}
voidaddcard()
{
inti=0;
charchoice;
for(i=0,choice='y';choice=='y'||choice=='Y';i++)
{
printf("\n\n卡号:
");
scanf("%d",&card[i].cardnum);
printf("\n性别:
");
scanf("%s",card[i].sex);
printf("\n姓名:
");
scanf("%s",card[i].membersname);
printf("\n电话:
");
scanf("%ld",&card[i].memberstel);
printf("\n\n是否要输入下一个人===============(y\\n)\n\n");
scanf("%s",&choice);
}
printf("\n\n-----------------输入完毕.");
printf("\n---------------任意键返回...\n");
getch();
}
delcard()
{
inti;
intcardnum;
charchoice;
printf("\n\n要删除的卡号:
");
scanf("%d",&cardnum);
for(i=0;i<5;i++)
{
while(card[i].cardnum==cardnum)
{
printf("\n\n确认删除?
(Y/N)\n");
scanf("%s",&choice);
if(choice=='y'||choice=='Y')
{
{for(;i<5;i++)
card[i]=card[i+1];
}
printf("\n\n---------------已删除成功!
\n---------------按任意键返回...\n");
getch();
return0;
}
else
{printf("---------------已取消删除\n\n");getch();return0;}
}}}
voidcardcount()
{
inti,n=0;
for(i=0;i<5;i++)
{if(card[i].cardnum!
=0)
{printf("第%d张卡\n",i+1);
printf("卡号性别姓名电话\n");
printf("\t\t\n");
printf("%d%6s%10s%ld\n\n",card[i].cardnum,card[i].sex,card[i].membersname,card[i].memberstel);
n++;
printf("\n");
}}
printf("---------------目前共有%d个会员.\n",n);
printf("---------------按任意键返回...\n");
getch();
}
voidaddcar()
{charchoice;
inti;
for(i=0,choice='y';choice=='y'||choice=='Y';i++)
{printf("\n\n\n编号:
");
scanf("%d",&car[i].carnum);
printf("\n\n车型:
");
scanf("%s",car[i].carname);
printf("\n\n品牌:
");
scanf("%s",car[i].carcreat);
printf("\n\n租金:
");
scanf("%f",&car[i].carprice);
printf("\n\n请你设定车的状态===============(0-不在\\1-在):
");
scanf("%d",&car[i].turefalse);
printf("\n\n是否要输入下一辆车===============(y\\n)\n\n");
scanf("%s",&choice);
}
printf("\n\n-----------------输入完毕.");
printf("\n---------------任意键返回...\n");
getch();
}
delcar()
{
inti,carnum;
charchoice;
printf("\n\n");
printf("编号:
\n");
scanf("%d",&carnum);
for(i=0;i<5;i++)
{while(carnum==car[i].carnum)
{printf("确认删除-----(y/n)?
\n");
scanf("%s",&choice);
if(choice=='y'||choice=='Y')
{{for(;i<5;i++)car[i]=car[i+1];}
printf("\n\n---------------已删除成功!
\n---------------按任意键返回...\n");
getch();
return0;
}
else
{printf("---------------已取消删除\n\n");}
}}
printf("--------------------按任意键返回...\n");
getch();
return0;}
voidcarcount()
{
inti,n=0;
for(i=0;i<5;i++)
{if(car[i].carnum!
=0&&car[i].carname!
=0)
{
printf("\n\n第%d辆车\n编号车型品牌租金状态\n",i+1);
printf("\t\t\n");
printf("%d%10s",car[i].carnum,car[i].carname);
printf("%15s%4.2f%d=====(1在\\0不在)\n\n",car[i].carcreat,car[i].carprice,car[i].turefalse);
n=n+1;
}}
printf("\n\n---------------目前共有%d辆车.\n",n);
printf("---------------按任意键返回...\n");
}
voidend()
{printf("\n\n\n-------------------------------------------------------------------------------\n");
printf("\n");
printf("---谢谢使用本系统,再见!
---\n");
printf("\n\n\n\n");
}
voidmain()
{
charch1,ch2,ch4;
do
{
printf("\n");
printf("---制作:
学号:
班级:
---\n\n");
printf("\n---欢迎使用系统---");
printf("\n\n");
printf("请选择需要的服务:
\n");
printf("1:
查询汽车\n");
printf("2:
办理租赁\n");
printf("3:
管理系统\n");
printf("4:
归还登记\n");
printf("0:
退出系统\n");
printf("请输入数字0━4:
\n");
ch1=getch();
switch(ch1)
{
case'1':
chacar();break;
case'2':
lendcar();;break;
case'3':
{
do
{printf("\n\n1:
增加汽车\n");
printf("2:
删除汽车\n");
printf("3:
汽车统计\n");
printf("4:
会员管理系统\n");
printf("0:
返回首页\n");
printf("请输入0━4:
\n");
ch2=getch();
switch(ch2)
{
case'1':
addcar();break;
case'2':
delcar();break;
case'3':
carcount();getch();break;
case'4':
{
do
{
printf("\n\n1:
申请新卡\n");
printf("2:
删除卡号\n");
printf("3:
卡号统计\n");
printf("0:
返回\n");
printf("请输入0━3:
\n");
ch4=getch();
switch(ch4)
{
case'1':
addcard();break;
case'2':
delcard();break;
case'3':
cardcount();break;
case'0':
break;
default:
printf("无此操作!
\n");getch();break;
}
}while(ch4!
='0');}break;
case'0':
end();break;
default:
printf("无此操作!
\n");getch();break;
}
}while(ch2!
='0');}break;
case'4':
huancar();break;
case'0':
end();break;
default:
printf("无此操作!
\n");getch();break;
}
}while(ch1!
='0');
}