码迷,mamicode.com
首页 > 其他好文 > 详细

公交一卡通2

时间:2015-01-28 19:43:18      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

#include <stdio.h>
#include <unistd.h>
#include<windows.h>
void stop(void)
{

system("pause");
}

int main()
{
int stops=0,money=0; //先定义变量
char chose,choose;
system("cls");
printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||"); //第一界面
printf("\n\t\t||-------------Welcome----------||");
printf("\n\t\t||----------use bus traffic-----||");
printf("\n\t\t||--------------card------------||");
printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||");

printf("\n\n\n\n"); ///查找一下怎么清屏再写
Sleep(4000);
system("cls");


printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||");
printf("\n\t\t| 1.Add new card |");
printf("\n\t\t| 2.Logout card |");
printf("\n\t\t| 3.Modify card |"); //第二界面
printf("\n\t\t| 4.Read card |");
printf("\n\t\t| 5.Save money |");
printf("\n\t\t| 6.Stat.max money |");
printf("\n\t\t| 7.Display |");
printf("\n\t\t| 8.Delete |");
printf("\n\t\t| 0.Exit |");
printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||");

printf("\n\n\n");
printf("please give your change:");
scanf("%c",&chose); //chose 是自定义的 scanf 函数获取输入字符 !!!注意是字符型不是数字
switch(chose)
{
case ‘1‘:printf("\n\t\t Your chose is 1"); break;
case ‘2‘:printf("\n\t\t Your chose is 2"); break;
case ‘3‘:printf("\n\t\t Your chose is 3"); break;
case ‘4‘:printf("\n\t\t Your chose is 4"); ///输入界面
printf("\n\t\t please input your stops:");
scanf ("%d",&stops);
if (stops<1||stops>30)
{
printf("\n\t\t input error please try again");
getch(); //重新回到上一界面
}
else if (stops<=10) ///用else if
{
printf("\n\t\t Your ticket is 1");break; //记得break

}
else if (10<stops<=15)
{                                                                                   //无法返回上一级 ?????
printf("\n\t\t Your ticket is 2");break;

}
else if (15<stops<=20)
{
printf("\n\t\t Your ticket is 3");break;

}
else if (20<stops<=25)
{
printf("\n\t\t Your ticket is 4");break;

}
else if (25<stops<=30)
{
printf("\n\t\t Your ticket is 5");break;

}

case ‘5‘:printf("\n\t\t How much is your save:");
scanf ("%d",&money);
if (money <=0)
{
printf ("\n\t\t error !!!! please check it");
}
getch();
break;

case ‘6‘:printf("\n\t\t Your chose is 6"); break;
case ‘7‘:printf("\n\t\t Your chose is 7"); break;
case ‘8‘:printf("\n\t\t Your chose is 8"); break;


case ‘0‘:printf("\n\t\t Are you sure exit?(y/n)");
scanf("%c",&choose);
if (choose==‘y‘||choose==‘Y‘) ///字符型的加引号
{
exit(0);
}
default:("\n\t\t input error");
}
getch(); //why




stop();
return(0);

}

公交一卡通2

标签:

原文地址:http://www.cnblogs.com/blank-king/p/4256598.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!